BSD DevCenter
oreilly.comSafari Books Online.Conferences.


Read The Friendly Manpage! -- A Tutorial
Pages: 1, 2, 3

The next heading in every manpage is SYNOPSIS:

     who am I
     who [file]

Since we are in section 1 of the manpages, this is a very useful heading as it contains the syntax and switches used by the command. Here, the who command has two possible syntaxes which yield different results:

who am i
genisis   ttyp0   Sep 24 10:52
genisis   ttyv0  Sep 24 08:41
genisis   ttyv1  Sep 24 08:42
genisis   ttyv2  Sep 24 08:42
genisis   ttyv3  Sep 24 09:06
genisis   ttyv4  Sep 24 09:14

To understand the meaning of all the syntax options, scan the DESCRIPTION heading which immediately follows the SYNOPSIS.

The who utility displays a list of all users currently logged on, showing for each user the login name, tty name, the date and time of login, and hostname if not local.

Available options:

am I

Returns the invoker's real user name.


By default, who gathers information from the file /var/run/utmp. An alternate file may be specified which is usually /var/run/wtmp (or /var/run/wtmp.[0-6] depending on site policy as wtmp can grow quite large, and daily versions may or may not be kept around after compression by ac(8)). The wtmp file contains a record of every login, logout, crash, shutdown and date change since wtmp was last truncated or created.

The DESCRIPTION heading for who is fairly short and intuitive once you've tried running the command both ways. Let's look at a manpage with a longer DESCRIPTION:

man ls
LS(1)   FreeBSD General Commands Manual   LS(1)

     ls - list directory contents

     ls [-ABCFGHLPRTWabcdfgiklnoqrstu1] [file...]

Unlike the who command, which had no switches, the SYNOPSIS for the ls command looks like the ingredients in alphabet soup. Note that the only part of the synopsis that is not enclosed by [] is ls itself; this means that all switches and files are optional. If you just type:


you will still get a listing of your current directory.

Remember that to Unix, everything is a file, including directories. So:

ls /etc

will list the directory contents of /etc.

ls /etc/rc.conf

won't yield much, but

ls -l /etc/rc.conf

will yield information on the rc.conf file.

The SYNOPSIS shows all legal switches, but the DESCRIPTION heading explains the usage of each switch, in the order they were listed in the SYNOPSIS. If I wish more information on what -l does, I can either use my page down key to look for it, or type:

/ -l

to invoke the search function and receive the following explanation:


(The lowercase letter ``ell.'') List in long format. (See below.) If the output is to a terminal, a total sum for all the file sizes is output on a line before the long listing.

One can then page down and look for the "long format," or keep pressing the / key until one finds it:

The Long Format

If the -l option is given, the following information is displayed for each file: file mode, number of links, owner name, group name, number of bytes in the file, abbreviated month, day-of-month file was last modified, hour file last modified, minute file last modified, and the pathname. In addition, for each directory whose contents are displayed, the total number of 512-byte blocks used by the files in the directory is displayed on a line by itself immediately before the information for the files in the directory.

Pages: 1, 2, 3

Next Pagearrow

Sponsored by: