UNIX Cheat Sheet

Here is a video where I use many of these commands: - CS210 Weekly Assignments: Unix tutorial (Setting up)

Help

man {command}- To get more information on any of the commands on this page. EG. man man
man 3 {C command} - To get information about a C command.
- If you get an error like "Implicit declaration of {C command}, use man 3 {C command} to see if there is a library you need to include.
- Note: This does not work on our server, so use Google instead.
whatis- To get more information on any of the commands on this page. EG. whatis whatis
man -k {part of command}- If you cannot remember the full command name. E.g. man -k what

Make an Alias

alias {name}="{command}" - e.g. alias drbcsubmit="/y/shared/Engineering/cs-drbc/submit"
- Now you can type drbcsubmit instead of the whole command name.
- See the video

here

to make this a permanent change.

Submit Your Assignments (Set up and Alias first)

drbcsubmit- Get a list of options.
- See the video

here

for more information about using the submit program.
drbcsubmit ? {class} {asn} - Get the instructions for {asn} eg:
drbcsubmit ? cs210 w01
drbcsubmit {file} {class} {asn} - Submit {file} as {asn} eg:
drbcsubmit ? cs210 w01

Create and destroy directories

mkdir {directory} - Create a new directory. EG. mkdir cs210
rmdir {directory} - Delete {directory} if it is empty
rm -r {directory} - Delete {directory} and all of its contents. BE CAREFUL!
cp -r {dir 1} {dir 2} - copy {dir 1} to {dir 2}

Navigate to directories

cd- Go to your home directory
cd {directory} - Go to a sub {directory} of the one you are in.
cd .. - Go up to the parent of the directory you are in.
cd - - Go back to the last directory you were in.
pwd- Tell what directory you are in.

List the contents of a directory

ls- Show the contents
ls -a- Show the hidden files as well. (Note hidden files start with .)
ls -l- Get even more information

Manipulating files

vi {file}- Create/edit {file}.
- See the video

here

for more information about vi.
cp {old name} {new name}- Copy a file.
mv {old name} {new name}- Rename a file.
- This also works for directories.
rm {file}- Delete (remove) {file}
cat {file}- Print the contents of a {file} all at once
more {file}- Print the contents of a {file} one screen at a time.
- Press [space] to continue or q to quit.