i-Lab Guide To: Linux Commands

The following tables lists useful commands (for developers) in Unix and its many (GNU) Linux flavours. Use man <commandname> to find out more...

Tool/Usage

Description

at

Run command at a particular time
awk [-f <script>] <files> Pattern-matching text-processing language
bc Command-line calculator (actually rather more than that)
cat <files> Just like MS-DOS's TYPE command
cmp Fast diff for binary files
compress <files> Packs a file and appends .Z to the filename (e.g. "compress *.backup")
cut <options> <files> Cuts specific columns from text file (e.g. "cut -c 12-21")
df <paths> Gives space left on disk (e.g. "df .")
dircmp Directory contents comparison
du <paths> Gives space used by files directories (e.g. "du ~")
expr Allows arithmetic to be performed in a script
fastboot <options> Reboots machine (if logged-in as root), e.g. "fastboot -l"
file <files> Displays guessed type for the supplied file
find <paths> <expression> Searches for files that meet criteria (e.g "find . -name STRING -print")
fold Perform word-wrapping at a specified column (default 80)
grep <pattern> <files> Search for occurences of a string (or just counts occurences with -c option)
head <options> <files> Lists first n lines of a file (e.g. "head -4 ada.lib")
hostname Returns this machine name
join Merge lines from files matching first column
kill [-s <signal>] <pid> Kills off a proces by process ID (or kill -l to list signals)
line Used as a pausing point in a script
ln Creates a symbolic file link (e.g. "ln -s ACTUAL_PATH LINK_NAME")
lpstat Prints output status of all printers (e.g. "lpstat -o")
nice <command spec> Runs command with lower priority
nohup <command spec> Carries command on even after log-out

od <files>

Displays the contents of a data file in octal (or hex using -X)
paste Merge lines from files in columns

pmap <pid>

Shows memory usage of shared libraries

ps <options> Displays process statuses (e.g. "ps -auxww | more")
rsh <hostname> <command> Runs a single command on another computer (e.g. "rsh poplar ps -aux")
script Records all shell I/O to file (CTRL-D to stop)
sdiff Visually displays file differences (e.g. "sdiff file file2 | more")
sed Stream line editor
sort Sorts a text-file. -u removes duplicates (e.g. "who | sort -u")

strace <command>

System-call tracer

stty Set terminal options
tail <options> <files> Lists last n lines of a file (e.g. "head -4 ada.lib")
tar Archives (tar -cf *.a) and de-archives (tar -xf TAR_FILE)
tee Copies input to file as well as to screen

top

Continuously displays the most CPU intensive processes

tr Replaces all occurences of one character with another
trace Follows all system-calls for a (non-shell) command
uname Prints Unix version (e.g. "uname -ru")
umask Sets default file permissions using octal (e.g. "umask 022")
vi Fast but unfriendly text editor favoured by "guru" programmers

vmstat

Reports a summary of system utilisation

wc File word count (wc -w <filename>) or line count (wc -l filename)
who Lists users currently logged-in to a machine
whoami Returns current user name
xargs Creates a list of filenames to run a particular file on

© 2006 i-Lab Limited