Man Command Usage With Examples For Linux and Unix

RSS
EMAIL
FACEBOOK
FACEBOOK
GOOGLE
GOOGLE
https://www.poftut.com/man-command-usage-examples-linux-unix/
PINTEREST
PINTEREST
INSTAGRAM

Linux man command is number one helper to get more detailed information about Linux commands. There are different alternatives like info but man is de-facto command for help. In this tutorial we will look various usage examples of man command.

Syntax

View Man Page

Most common usage for man command is listing a command, tool, library usage simply. We will list manual for ls command like below.

View Man Page

View Man Page

Sections

Manual pages are categorized into sections. Each command, tool, library have a section. Categorization is made according to relevance of command, tool, library. Each section have a number from 1 to 9

  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 eg /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 [Non standard]

View Man Page For  Specific Section

Sometimes there may be more than one tutorial about some expression. But those manual sections are different. For example print have more than one manual. We will look for section 1 manual with the example below.

View Man Page For  Specific Section

View Man Page For Specific Section

List Sections For A Command

We may want to list sections for a command, library or function. We will use man pages file to search and list. In the example we will look printf command manual pages.

List Sections For A Command

List Sections For A Command

We can get section numbers from file name and directory name.

LEARN MORE  10 Things To Do After Fedora Installation

View All Man Pages For A Command

Another usage form for man pages is viewing all pages in a single command. Manual pages will be printed in a string mode. In order to quit from pages use q shortcut. We will use -a option to list all manual pages for printf command.

View Man Page In Browser

Another useful feature is viewing man pages in a browser. This is more human friendly way to read manuals but keep in mind that this will require GUI desktop. First we will set BROWSER variable for the command line interface bash and than use -H parameter with related command which is printf in this situation.

Search Man Page NAME Section

Man pages have different sections too. These are used to define part names. Here are these sections.

  • NAME contains name of the command and short explanation
  • SYNOPSIS contains usage syntax
  • DESCRIPTION contains more detailed explanation
  • OPTIONS contains all options about command
  • HISTORY contains history about the command and persons

Search Man Page NAME Section

Search Man Page NAME Section

Search Man Page NAME and DESCRIPTION Section

In previous example we have only searched in NAME section. We may want to get more results and search in DESCRIPTION section too. We will provide -k option like below.

Search Man Page NAME and DESCRIPTION Section

Search Man Page NAME and DESCRIPTION Section

RSS
EMAIL
FACEBOOK
FACEBOOK
GOOGLE
GOOGLE
https://www.poftut.com/man-command-usage-examples-linux-unix/
PINTEREST
PINTEREST
INSTAGRAM

You may also like...

Leave a Reply

Your email address will not be published.

Enjoy this blog? Please spread the word :)