next up previous contents
Next: Creating new directories Up: First Steps into Previous: Moving around

Looking at the contents of directories

          Now that you know how to move around directories you probably think, ``So what?'' The basic skill of moving around directories is fairly useless, so let's introduce a new command, ls. ls prints a listing of files and directories, by default from your current directory. For example:

Here we can see that Larry has three entries in his current directory: Mail, letters, and papers. This doesn't tell us much---are these directories or files? We can use the -F option on the ls command to tell us more.

From the / appended to each filename, we know that these three entries are in fact subdirectories.

    Using ls -F may also append `` *'' to the end of a filename. This indicates that the file is an executable, or a program which can be run. If nothing is appended to the filename using ls -F, the file is a ``plain old file'', that is, it's neither a directory, or an executable.

In general, each UNIX command may take a number of options in addition to other arguments. These options usually begin with a `` -'', as demonstrated above with ls -F. The -F option tells ls to give more information about the type of the files involved---in this case, printing a / after each directory name.

If you give ls a directory name, it will print the contents of that directory.

Or, for a more interesting listing, let's see what's in the system's /etc directory.

(For those MS-DOS users out there, notice how the filenames can be longer than 8 characters, and can contain periods in any position. It is even possible to have more than one period in a filename.)

Let's cd up to the top of the directory tree, using `` cd ..'', and then down to another directory: /usr/bin.

You can also move into directories in multiple steps, as in cd /usr/bin.

Try moving around various directories, using ls and cd. In some cases, you may run into a foreboding `` Permission denied'' error message. This is simply the concept of UNIX security kicking in: in order to ls or to cd into a directory, you must have permission to do so. We'll talk more about this in         Section 3.9.



next up previous contents
Next: Creating new directories Up: First Steps into Previous: Moving around



Ross Biro
Tue May 23 13:39:28 PDT 1995