command line, linux, shell

Linux man pages

Linux manual pages, often called man pages are the documentation available in command line. Even we have much information in Google nowadays, those still are very useful because they are accessible from the command line straight away. Typically include details about specific program options, rather than answers on more general questions, why some thing does not work as expected.

Sections

Man pages are structured and divided into sections, to make your life a little bit easier:

Section |  Contents
----------------------------------------------
   1    |  User-level commands and applications
   2    |  System calls and kernel error codes
   3    |  Library calls
   4    |  Device drivers and network protocols
   5    |  Standard file formats
   6    |  Games and demonstrations
   7    |  Miscellaneous files and documents
   8    |  System administration commands
   9    |  Obscure kernel specs and interfaces

man command sends a specific manual page to your terminal through more, less or any other editor specified in PAGER environment variable.

Usage

To get all of the information just type man <program_name>

$ man systemctl
SYSTEMCTL(1)                                                                             systemctl                                                                            SYSTEMCTL(1)

NAME
       systemctl - Control the systemd system and service manager

SYNOPSIS
       systemctl [OPTIONS...] COMMAND [UNIT...]


[...]

To dive into specific version, eg system calls, type man 2 sync

Searching

man -k <keyword> or apropos <keyword> searches man pages that have <keyword> in their synopses, eg:

$ man -k ssh
man: can't set the locale; make sure $LC_* and $LANG are correct
scp (1)              - OpenSSH secure file copy
sftp (1)             - OpenSSH secure file transfer
sftp-server (8)      - OpenSSH SFTP server subsystem
ssh (1)              - OpenSSH remote login client
ssh-add (1)          - adds private key identities to the OpenSSH authentication agent
ssh-agent (1)        - OpenSSH authentication agent

[...]

Those search results can be outdated. If you add some packages or man pages itself, you need to rebuild the database with mandb command.

The current search path can be found with manpath command. If necessary, this path can be overriden by setting MANPATH environment variable

$ manpath
/usr/local/man:/usr/local/share/man:/usr/share/man

$ export MANPATH=/some/other/source

$ manpath
/some/other/source