Change Directory (cd)
cd Change directory to your home directory cd .. Change directory to the parent directory cd bob Change directory to the directory bob cd ~child Change to a user home directory
Copy (cp)
cp bob fred Copy the file bob to fred cp *.bob .. Copy all files *.bob into the directory above cp -r bob /tmp Copy the directory bob and all of it's contents into /tmp cp ../bob . Copy the file bob from the directory above to the current directory.
List Files (ls)
ls -ltr license.* Display all license.* files in order of time modified ls -lg Display the long listing for the directory plus group ownership ls -a Display all files including .files (hidden)
Move Files (mv)
mv bob fred Move the file bob to fred mv bob .. Move the directory bob up one directory
Remove Files (rm)
rm bob fred Remove the files bob and fred rm -r bob Remove the directory bob and all of the files in it rm -i *.bob Prompt to remove all of the .bob filesNote: The following commands are a very poor idea:
rm -r * Delete all of the files and directories from here down. rm -rf .* Delete all of the files that you own on the current disk.
Remove Directory (rmdir)
rmdir bob fred Remove the directories bob and fredNote: The directories must be empty.
Make Directory (mkdir)
mkdir bob Make a subdirectory bob in the current directory
File type (file)
file bob Find out what type of file bob is
View files (more)
more bob View a file if it is text, page by page more *.bob View all files that match *.bobNotes: Keys to navigate
Display File (cat)
cat bob Display the entire file bob to the screen with no control
Display the end of a file (tail)
tail -20 bob Display the last 20 lines of bob to the screen
Display the beginning of a file (head)
head -33 bob Display the first 33 lines of bob to the screen
Print File (lpr)
lpr bob Print the file bob to the default printer lpr -Pqms1 bob Print the file bob to the printer named qms1
Check print queue (lpq)
lpq See what files are being printed to the default printer lpq -Pqms1 See what files are being printed to qms1
Remove a file from print queue (lprm)
lprm 10 Remove job #10 from the default print queue lprm -Pqms1 20 Remove job #20 from the print queue for qms1Note: Only works for your own jobs.
Jobs running (subprocess) (jobs)
jobs Show current subprocesses
Kill a job (kill)
kill %1 Kill the first subprocess (as reported by jobs) kill 2014 Kill process number 2014 kill -9 2014 Really kill process 2014 (messy)
Put a job in the background (bg)
bg %1 Put the first subprocess (as reported by jobs) in the background pts & Run pts in the background
Bring a job into the foreground (fg)
fg %1 Bring the first subprocess (as reported by jobs) into the foreground
Changing directory with a memory (pushd)
pushd /tmp Add /tmp to the directory stack and go there pushd +2 /tmp Swap /tmp with the 2nd element in the stack and go there.
Show the directory stack (dirs)
dirs Show the directory stack.
Changing directory with a memory (popd)
popd Remove the top element from the stack and go to the top element popd +2 Remove the 2nd element from the stack.
Questions, comments, suggetions or corrections to jot@tmp.medtronic.com http://www.tmp.medtronic.com/~jot/unix-class/commands.html