Penguin

Must Read

I think a lot of people use the man command without knowing they can specify a section number to get more relevant information.

For example a person without the knowledge of man sections may want to know the structure of the 'passwd' file and type 'man passwd'. They receive a page telling them all about the 'passwd' command and they assume the information they seek is not available using man, when really it is.

Thanks to : http://www.linux-tutorial.info

When referring to a particular command in Linux documentation, you very often will see the name followed by a letter or number in parenthesis, such as ls(1). This indicates that the ls command can be found in section 1 of the man-pages. This dates back to the time when man-pages came in books (as they often still do). By including the section, you could more quickly find what you were looking for.

For a list of what sections are available, see the table below or the man man-page. If you are looking for the man-page of a particular command and know what section it is in, it is often better to specify the section. Sometimes there are multiple man-pages in different sections. For example, the passwd man-page in section 1 lists the details of the passwd command. The passwd man-page in section 5, lists the details of the /etc/passwd file. Therefore,if you wanted the man-page on the passwd file, you would use:

  • man 5 passwd

Here is a list of the sections and a brief description of what can be found in each section:

1) Commands, Utilities and other executable programs, which are typically user-related 2) System calls 3) Library calls 4) Special files, typically device files in /dev 5) File formats and their respective conventions, layout 6) Games 7) Macro packages 8) System administration commands 9) Kernel routines

Not happy with your default man viewer?

Then change it! This is easily done by setting the 'PAGER' environment variable.

I am using Debian Etch which by default uses 'less' as the man viewer. But say I want to use 'more' to view man pages instead.

  • export PAGER="/path/to/more"

Now type 'man ls' for example, and notice the man viewer has changed :)

If you regret the change simply do:

  • unset PAGER

to revert back to the default man page viewer.

Remember, to make changes to an environment variable permanent you will have to add the export command to your shell initialization script.

You can Search a man Document

Note: This only applies when using 'less' to view man pages.

When viewing a man for a particular application, you can search for a keyword you are after by typing:

  • /<search>

The man will scroll down to the first match, and any matches will be highlighted!

To search backwards:

  • ?<search>

Help I forgot the name of a command!

In the man command you can specify a keyword to search for inside the description of the command you are looking for. For example if you remembered the application had something to do with partitioning:

  • man -k partition

Results in:

cfdisk (8)           - Curses based disk partition table manipulator for Linux
fdisk (8)            - Partition table manipulator for Linux
parted (8)           - a partition manipulation program
partprobe (8)        - inform the OS of partition table changes
sfdisk (8)           - Partition table manipulator for Linux

With a bit of luck you will find the name of the application you are after :)

Manual pages about using GNU/Linux for development

Forgotten the syntax for that c function? Not to worry!

  • sudo aptitude install manpages-dev

Now you can do something like:

  • man 3 printf

and receive a man page providing comprehensive information about how to use the printf function.

Note : man section 3 = Library calls (functions within program libraries)

MANSECT Environment Variable

Its value is a colon-delimited list of sections and it is used to determine which manual sections to search and in what order.

For example :

  • export MANSECT="3:1:5:2:4:8:9:7:6"

CategoryNotes