The contents of a directory can be displayed using the ls command:
ls [-alRsC] filename...where filename... is one or more file or directory names.
By default, SunOS and DEC ULTRIX use the -C flag. SGI IRIX does not. For that reason, many SGI IRIX users set an alias for ls to ls -C.
Examples of the above flags follow.
Note: many more flags are available. For more information, see the documentation relating to your system or use man ls.
ls by itself lists the content of the current working directory, in alphabetical order:
prompt> lscourse.tex course.toc unixug prompt>
The -a (all) option, lists all files, including those beginning with a dot (.). The current directory is represented as . (dot) and the parent directory, by .. (dot dot):
prompt> ls -a. .. course.tex course.toc unixug
The -l (long) flag will produce a long listing:
prompt> ls -ltotal 303 -rw-r--r-- 1 cantin 19347 Dec 11 10:12 course.tex -rw-r--r-- 1 cantin 2520 Dec 11 09:53 course.toc -rw-r--r-- 1 cantin 1978 Dec 7 09:14 unixug
The first line of the listing gives the total storage area taken by this directory, in kilobytes.
The first character of the first field indicates the type of file (- means an ASCII file, d a directory, l a symbolic link). The next nine characters indicate the permissions on the file. The next field is the number of links, i.e. the number of copies of that file on the file system (normally 1). The third field shows the owner, the fourth the size of the file (in bytes), the fifth the last modified time, and the last field the name of the file. Note that the Silicon Graphics IRIX adds a group field after the owner field.
-s displays the size of each file, its size in kilobytes for Suns and in blocks of 512 bytes for SGIs.
prompt> ls -s
total 303
19 course.tex 3 course.toc 2 unixug
Any combination of flags is allowed:
prompt> ls -lsa
total 305 1 drwxr-xr-x 2 cantin 512 Dec 11 10:14 . 1 drwxr--r-- 9 cantin 512 Dec 5 12:09 .. 19 -rw-r--r-- 1 cantin 19347 Dec 11 10:12 course.tex 3 -rw-r--r-- 1 cantin 2520 Dec 11 09:53 course.toc 2 -rw-r--r-- 1 cantin 1978 Dec 7 09:14 unixug