next up previous contents
Next: Setting and showing your Up: Files and the File Previous: Searching a file (grep)   Contents

Listing the files in a directory (ls)

Like VMS, Unix stores all files in a directory. When you initially log in Unix sets the default to your home directory. A directory is a special type of file. Unix has commands specifically designed to deal with directories. Right now we should introduce the command ls, which lists the contents of a directory. The format for ls is:

ls filename

If you do not give a filename, the current directory is listed. The command may also be used with individual files. If you type ls and a filename, ls repeats its name and any information requested. You can get certain information about a file by using the options available with the command ls.

malama% ls -s params
4 params
malama%

The option -s tells the system to print the size of the file in blocks (2 blocks is a kilobyte, as with VMS). You can use the -s option when listing a directory and it will list each file in the directory with its size.

While on the topic of options available with ls, we should mention two very useful options: -a and -F . -a will include all files whose names start with ``.'', which are normally hidden. Important files, such as ``.login'' (your login file) will only be listed if you use the -a option. There may be situations where you don't particularly care to see these, as in general they have special functions. -F (note uppercase), will distinguish different types of files by placing a symbol after the name, for example, directories with a /, and executable files with a *. You may wish to ``alias'' (see later) ls permanently to e.g. ``ls -sF'' in your .login file.


next up previous contents
Next: Setting and showing your Up: Files and the File Previous: Searching a file (grep)   Contents
h.stilmack@jach.hawaii.edu