To obtain a list of all the files in a specified directory, use the
ls command.
% ls
will list the names of all the files in the current working directory. The names will be listed in a series of columns, and in alphabetical order working down successive columns. The command can be restricted to reporting information about a single file or about a group of files by giving a filename or a wildcard specification as an argument.
To obtain more information about individual files, use the l option,
which gives a longer listing, with one file per line. There are a number
of 'hidden' files that may be present in a directory; the a option
ensures that all these are shown on the listing.
Example
% ls - al
drwxr-xr-x 5 fred 512 Jul 8 11:57 . drwx-rxr-x 21 root 512 Jun 26 09:24 .. -rwxr-x--x 1 fred 397 Jul 5 10:30 .cshrc -rwxr-x--x 1 fred 321 Jul 5 10:29 .login -rwxr-x--x 1 fred 182 May 29 09:44 .profile -rw-r--r-- 1 fred 2490 Jul 8 11:42 ALAN.TXT -rw-r--r-- 1 fred 3623 Jul 8 11:42 CATANP.TXT drwxr-x--x 2 fred 512 Jul 8 11:28 bin drwxr-xr-x 2 fred 512 Jul 8 11:53 data drwxr-xr-x 2 fred 512 Jul 8 11:33 plants -rw-r--r-- 1 fred 20 Jul 8 11:38 plantlist -rwxr-x--x 1 fred 241 Jul 8 11:35 try1 -rwxr-x--x 1 fred 321 Jul 8 11:35 try1~
The above example shows that you can combine two options (a and
l) together on the command line. Each output line shows, in sequence,
the access modes, link count, owner, size (in characters), date and time
of last modification and finally the filename for each file.
The files beginning with a full stop (.) are special or
'hidden' files that are only shown with the use of the a option.
The two top files are special files referring respectively to the current
directory (.) and the parent directory (..). The
remaining 'hidden' files in this example (.cshrc, .login
and .profile) are initialisation files that are responsible
for setting a number of options and environmental variables for the session.
The access modes for each file consist of 10 characters. A d in
the first position indicates that the file is a directory file (as in
bin, data and plants above for example).
The remaining nine characters are three sets of three access codes. Each
set can have r (for read), w (for write)
and x (for execute) permission granted, the three sets
referring to the owner of the file, the group to which the owner belongs
and the world respectively. On the OUCS machines, a group consists
of all users from the same department while the world refers to all
registered users. These access modes can be altered using the chmod
command.
To display the contents of a file on the screen use the
cat command.
Example
% cat plantlist
If the file is long, you may wish to scroll the display up a screenful
at a time to allow you to read it. To do this, use the more program.
% more plantlist
The display will pause at the end of each screenful, at which point the
same series of sub-commands described above for the man command
may be used.
To print a file use the lpr command.
Example
% lpr plantlist
will cause the file plantlist to be printed on the default printer attached to the system.
For the OUCS machines, files are printed by default on the central lineprinter in the computer room at 13 Banbury Road. For details of how to print on any OUCS printer from linux.ox.ac.uk or the Convex, see [1] and [2].