Featured image

Table of Contents Link to heading

Man Pages Link to heading

or manual pages, provide a basic description of the purpose of the command/program/system files, as well as details regarding available options.

  • The man command uses a pager to display documents. This pager is either the more and the less command.

Viewing Man Pages Link to heading

  • For example, to view a man page for the ls command: man ls.
  • Use the arrow keys to navigate the document.
  • Use the spacebar to move down one screen.
  • Use the h to see a list of movement commands.
  • Use the q key to exit the man page.

man ls

Man Page Sections Link to heading

  • Man pages are broken into sections, each being designed to provide specific information about a command.
  • The following describes some of the more common sections found in man pages:
    • NAME: Provides the name of the command and a very brief description.
    • SYNOPSIS: Provides examples of how the command is executed.
    • DESCRIPTION: Provides a more detailed description of the command.
    • OPTIONS: Lists the options for the command as well as a description of how they are used
    • FILES: Provides a more detailed description of the command.
    • AUTHOR: Provides the name of the person who created the man page and (sometimes) how to contact the person.
    • REPORTING BUGS: Provides details on how to report problems with the command.
    • COPYRIGHT: Lists the options for the command as well as a description of how they are used.
    • SEE ALSO: Provides you with an idea of where you can find additional information. This often includes other commands that are related to this command.

Searching Man Pages Link to heading

  • To search a man page for a term, press the / and type the term, followed by the Enter key.
  • Searches are not case sensitive and do not “wrap” around from the bottom to top, or vice versa.
  • If the term is not found, or upon reaching the end of the matches, the program will report Pattern not found (press Return).
  • If a match is found, to move to the next match of the term, press n. To return to a previous match of the term, press N.

Man Page Categorisation Link to heading

  • There are thousands of man pages on a typical Linux distribution.

  • To organise all of these man pages, they are categorised by sections.

  • By defaults, there are nine default sections of man pages:

    1. Executable programs or shell commands
    2. System calls (functions provided by the kernel)
    3. Library calls (functions within program libraries)
    4. Special files (usually found in /dev)
    5. File formats and conventions, e.g. /etc/passwd
    6. Games
    7. Miscellaneous (including macro packages and conventions), e.g., man(7), groff(7)
    8. System administration commands (usually only for root)
    9. Kernel routines
  • The man command searches each of these sections in order until it finds the first match.

  • For example, if you execute the command man zed, the first section (General Commands) is searched for a man page called zed. If not found, then the second section is searched. If no man page is found after searching all sections, the shell returns a ‘No manual entry for zed’ error.

  • Sometimes, there are man pages with the same name in different sections. To list all man page sections for a name, use the -f option (equivalent to the whatis command). man-f

  • For instance, to display the passwd man page located in section 5: man5

  • Sometimes, you may not remember the exact name of the command. In these cases, use the -k option with a keyword argument to display a summary of all man pages that have that keyword in their description as regular expression (equivalent to the apropos command). man-k

Finding Commands and Documentation Link to heading

  • To search for source files and man pages of a command in specific locations where these files are typically stored, use the whereis command. whereis
  • Man pages are easily distinguished from commands as they are typically compressed with a program called gzip, resulting in a filename that ends in .gz.

Finding Any File or Directory Link to heading

  • To find any file or directory, use the locate command.
  • It searches a database of all files and directories that were on the system when the database was created.
    • However, any files created on that day will not be searchable with the locate command because the database is updated nightly.
    • It is possible to update the locate database manually by running the updatedb command as root.
  • When using the locate command as a regular user, the output may be limited due to file permissions. If the current user does not have access to a file or directory on the filesystem due to permissions, the locate command will not return those names. The root user can search for any file in the locate database.
  • To return a detailed listing of all outputs, pass them to ls -l. locate
  • The output can be quite large, so it may be helpful to use the following options:
    • The -c option prints the total number of matching files. locate*c
    • The -b option only includes listings that have the search term in the basename of the filename (but still printed, more useful when using in conjunction with -c option). The basename is the portion of the filename not including the directory names. locate*b
    • To limit the output even further, place a \ character in front of the search term. This character limits the output to filenames that exactly match the term. locatebackslash

Info Documentation Link to heading

  • The info command also provides documentation on operating system commands and features. Its goal include:
    • Providing a documentation as a logical organisational structure, making reading documentation easier.
    • Breaking down information into categories that work much like a table of contents in a book. Hyperlinks are provided to pages with information on individual topics for a specific command or feature.
  • Consider man pages to be more of a reference resource and info documents to be more of a learning guide.
  • For example, to display the info page of the ls command: info ls. infols
  • Navigate the document using the arrow keys.
  • This documentation is broken up into nodes. In the example, the line highlighted in white shows it is currently in the ls invocation node. The first line provides index information about the current location within the document. The next node, like the next chapter in a book, would be the dir invocation node. Going up one level is the Directory listing node.
  • A listing of movement commands is available by hitting the Shift+h key while reading the info documentation.
  • To quit the info documentation, use the q key.
  • Instead of using info documentation to look up information about a specific command or feature, consider exploring the capabilities of Linux by reading through the info documentation. Execute the info command without any arguments to be taken to the top level of the documentation. This is a good starting point to explore many of the features offered. info

Additional Sources of Help Link to heading

Using the Help Option Link to heading

  • Many commands will provide basic information, very similar to the SYNOPSIS found in man pages, by simply using the --help option to the command.
  • This option is useful to learn the basic usage of a command quickly without leaving the command line. –help

Additional System Documentation Link to heading

  • On most systems, there is a directory where additional documentation (such as documentation files stored by third-party software vendors) is found.
  • These documentation files are often called readme files since the files typically have names such as README or readme.txt.
  • Typical locations include /usr/share/doc and /usr/doc.
  • Typically, this directory is where system administrators go to learn how to set up more complex software services. However, sometimes regular users also find this documentation to be useful.