Unix Command Reference

Working with Files

Task Command Example
List ls ls -l
Copy cp fromfile tofile cp prog1.txt prog2.txt
Delete rm filename rm data.csv
Move mv frompath/fromfile tofile mv /scratch/bigdata.dta bigdata.dta
Rename mv oldname newname mv olddata.dta newdata.dta
Display the contents of a file more filename press the ENTER key to advance a line at a time; press the SPACE bar to advance a screen at a time; press CONTROL-C to end
Find find "directory" -name "filename" -print If you know the name of a file but not where it is, cd to your home directory and use 'find . -name "filename.txt" -print'

Working with Directories

Task Command Example
Show working directory pwd pwd
Change directory cd direcotryname cd jp
Change to home directory cd cd
Move one directory up cd .. cd ..
Create a directory mkdir directoryname mkdir thesis
Remove a directory rmdir directoryname rmdir olddir

Printing

Task Command Example
Print a file lpr -P printername filename lpr -P nslaser extract.sas
Check printer status lpq -P printername lpq -P nslaser
Cancel print job lprm -P printername jobnum lprm -P nslaser 123
List available printers printers -L printers -L | more

Other Commands

Task Command Example
Check how much disk space you can use quota -v quota -v
Edit a file using pico pico filename pico thesis1.do
Edit a file using vi vi filename vi thesis2.do
Modify access permissions chmod attrs filename chmod o+r pubinfo
Display environment variables env env
Display a calendar cal month year cal
Display current date and time date date
Help on a command man commandname man cp or lookup man pages
Help on a keyword man -k keyword man -k mail
See who is logged on who who
Look up someone's email address ph name ph Jane Doe
Page tags: commands unix
page_revision: 4, last_edited: 1193771014|%e %b %Y, %H:%M %Z (%O ago)
Unless otherwise stated, the content of this page is licensed under Creative Commons Attribution-ShareAlike 3.0 License