basic unix commands

There are many commands that one can use on the command line. A few of these are very important, and you will find yourself using them frequently during your CS experience.

Command Example Description
ls ls
ls -alF
The most basic use is to list the files and directories in the working directory. This is what you get if you just type ls on the command line. If you give ls a path to follow, such as ls ~/cs21, the result will be the contents of /home/you/cs21. Adding the -a option lists all files (including those starting with a dot, like your .bashrc file). The -l option lists files in the long format, and -F adds things like a / to indicate a dir, or a * to indicate an executable. Run man ls to see all the options.
cp cp file file.backup
cp file dir/.
Copies a file. Usage is cp original_file new_file.
mv mv file newfilename Moves or renames a file.
rm rm file_to_delete Removes or deletes a file. This may or may not ask if you really want to delete the file, so be careful. Use the -r option to remove a directory (or rmdir).
less less filename Allows you to read through a file. Shift+G will allow you to skip to the bottom without the file closing, which may come in handy.
cd cd dir_name Change directory. You can change directories to one in your current/working directory by typing cd dir_name. If you are working in /tmp, and want to go to your cs21 directory, you can type cd ~/cs21, or the full pathname of your target directory (e.g. cd /home/username/cs21).
mkdir mkdir dir_name Makes a new directory.
rmdir rmdir dir_name Deletes an empty directory. Use rm -r dir to remove directories and their contents recursively.
pwd pwd Print working directory (tells you where you are).

Other things to note: if you want to run a program, you can usually just type the program name, ie "python", "firefox", "update21", "handin21", or "mutt". If you type "man any_command_name" you should find a detailed list of instructions for using that command, as well as any options the command might have. Also, don't forget to check the rest of the help pages for any information you didn't find here.