Unix Command Reference

 

Default Terminal Keys

Rubout previous character <BackSpace> Erase this line C-u Stop console output C-s Resume console output C-q

Listing File Names: ls

List file names (alphabetical order) ls Show hidden files ls -a Show permissions ls -l List in chronological order ls -t

Displaying file contents

Print on console cat filename Print on printer lpr filename Print first n lines head [-n] filename Print last n lines tail [-n] filename Print one screenful at a time more filename Next page within more <Space> Previous page within more b Searching within more /pattern Print line(s) containing string grep string filename

Mail

Read your new mail mail Read your old mail mail -f Send from console to another user mail username Send file to another user mail [-s "subject"] username < filename

File Maintenance

Copy a file cp currentfilename copyfilename Delete a file rm filename Rename a file mv oldname newname Show differences between files diff leftfile rightfile In which directory is your file? find . -name filename -print

Directories

Show the current directory pwd Switch to a directory cd directoryname Back up one level in the tree cd .. Create a directory mkdir directoryname Remove a directory rmdir directoryname Moving a file to a directory mv filename directoryname (both must exist) Moving a directory to new location mv directoryname newparentdirectory (both must exist)

Date and Calendar

Date and time of day date Calendar cal [[mm] yyyy]

Users

Seeing who is logged in who or finger Getting a username finger lastname Changing identities su username Seeing who you are whoami who am i

Changing machines

Logging on to another machine rsh hostname Logging out from any machine logout Which machine is this? hostname

Information about a command

Man pages man command Starting Infoexplorer info

Filename substitution

Wild card symbols ? * Your home directory ~ Home directory of another user ~username

I/O redirection and pipes

Standard output > Standard input < Append to standard output >> Pipes/pipelines |

Sorting

Sort alphabetically on first word sort Sort in numeric order sort -n Sort on n+1 st field sort +n

tcsh command history

List previous commands history Repeat previous command !! Move up in history list Ctrl-p (previous) Move down in history Ctrl-n (next) Cursor left to edit command Ctrl-b (backwards) Cursor right to edit command Ctrl-f (forwards) Delete character in command Ctrl-d Repeat nth command in history !n Repeat command beginning with str !str

tcsh, csh job control

Run command in the background command & Stop foreground job C-z Run stopped job in foreground fg Run stopped job in background bg List background jobs jobs Bring job foreward %[n] Run command at lower priority nice command

tcsh miscellaneous

Filename, command name completion <Tab> List possible completions Ctrl-d Spelling correction ESC s Define alias alias name 'definition'

csh environment

List current settings env Change setting setenv VARIABLE value

Process control

List your processes ps Tell a process to die kill PID Kill without mercy kill -9 PID Timing time command