Go to the previous, next section.

Handling Files

Unix provides many commands to handle files. I will outline, briefly, the basic ones - ls, cd, cp, mv, and rm.

To use cd (change directory), you must give it an argument of which directory you wish to cd to. For example, if you're in your home directory and issue cd /usr/bin, you will be in the directory of /usr/bin. If you wish to check this, issue the command pwd (present working directory), which would give the output: `/usr/bin'

As an experiment, do a pwd of your home directory. What is this telling you?

The command ls will, among other things, list the contents of the current working directory. An ls of `/usr/man', will usually give the following output:

cat1    cat3    cat5    cat7    man1    man3    man5    man7    
manl    whatis  cat2    cat4    cat6    cat8    man2    man4    
man6    man8    mann

ls will probably be your most useful command. ls supports many options (also called switches). A few will be used in the following discussion. The commands cp, mv, and rm directly manipulate your files. cp copies files, mv moves (or renames) them, and rm removes them. If you wish to copy a file foo to a new file boo, enter:

cp foo boo

If you wish to move `boo' to `coo', enter:

mv boo coo

And finally, if you wish to remove `coo', enter:

rm coo

After reading the rest of the chapter on Unix Files, you will discover many different and interesting ways to manipulate files. You may also be wondering how to create files in general. Files are usually created by editors, compilers, or direct unix commands. After a while, files will seem to `pop' up all over!

Go to the previous, next section.