John Topley's Knowledgebase

Useful Linux/UNIX Commands

Friday, 30 May 2003

The following is a list of useful commands for accomplishing various tasks with Linux/UNIX.

Use these commands to:

  • Save manual page for name in ASCII format to filename:
man name | col -b > filename
  • Display all pages for name:
man -a name
  • Search man pages for keyword:
man -k keyword
  • Change pager used by man e.g. less:
man -P pagername
  • Start a new login session for username:
exec login username
  • Display login name:
logname
  • Logout:
Ctrl + D
  • Change username's password:
passwd username
  • Undo last directory change:
cd -
  • Go to home directory:
cd ~
  • Display current directory:
pwd
  • Change filename's modification time to current time:
touch filename
  • Display number of characters, words and lines in filename:
wc filename (wc -c, wc -w, wc -l)
  • Display disk space used:
du (du -a, du -s)
  • Identify file type of file filename:
file filename
  • Display disk space allocated to username:
quota (quota -v, quota -g, quota -g., quota username)
  • List all files beginning with foo:
ls foo*
  • List all files ending with .bar:
ls *.bar
  • List all files ending with a period and a single character:
ls *.?
  • List all files beginning with f or b:
ls [fb]
  • List all files beginning with a letter in the range b to f:
ls [b-f]*
  • List all files beginning with foo:
ls foo*
  • Find the largest file in the current directory:
ls -l | cut -c33-42 | sort -nr | head -1
  • Mount drive C: as FAT at /mnt/c:
mount -t msdos /dev/hda1/mnt/c:
  • Mount CD-ROM at /mnt/cdrom:
mount -t iso9660 /dev/hdc/mnt/cdrom
  • Unmount drive at mnt/foo:
umount /mnt/foo
  • Format a floppy disk:
fdformat /dev/fd0H1440
  • Create ext2 filesystem on a floppy disk:
mkfs -t ext2 -c /dev/fd0H1440
  • Display a list of running processes:
ps (ps -f, ps -l)
  • Run commands as a background process:
bg commands
  • Run process as a foreground process:
fg process
  • Leave command running after logoff:
nohup command &
  • List available kill signals:
kill -l
  • Determine what signal terminated the previous shell command:
kill -l $?
  • Display environment settings:
env
  • Display date and time:
date
  • Display a list of logged on users:
finger

top | index | previous | next | comments ()

home | archive | kb | media | about | contact | accessibility
Copyright © 2003 - 2005 John Topley. Made with CityDesk.