VMware ESXi and vSphere Cluster Management

Get help with Linux manual pages

Learn how to use Linux man pages, navigate the less pager, and find unfamiliar commands with man -k.

Linux commands are programs or shell instructions entered in a terminal, a text-based interface for running commands. Many commands accept arguments, options, and flags, so remembering every detail is difficult. Built-in documentation is usually the first place to look when you are learning a command or checking its exact usage.

What is a manual page?

A manual page, often called a man page, is locally installed reference documentation for a Linux command or system topic. It normally explains one command or topic at a time.

A manual page commonly includes:

  • The command's purpose or a short description
  • A synopsis showing the usual command syntax
  • Descriptions of arguments, options, and flags
  • Usage details and other information needed to run the command correctly

An option is an additional command argument that changes a command's behaviour. A flag is a short form of an option, commonly introduced with a hyphen, such as -k.

Opening a manual page with man

man is the utility used to open and search local manual-page documentation. Its general form is:

man COMMAND

Replace COMMAND with the name of the command you want to study. For example, to read about the command that lists files and directories, enter:

man ls

After pressing Enter, Linux opens the manual page for ls. Read the synopsis to see the command's general form, then review its description and options. The exact sections and amount of detail vary between commands, but the page is intended to be the command's reference guide.

Reading a man page with less

Long manual pages are normally displayed through less. Less is a pager: a program that lets you read lengthy terminal text one screen at a time instead of printing everything at once.

When a man page is open, the pager is active. The keys below work while you are viewing the documentation, not while you are typing at the shell prompt.

KeyAction while reading a man page
SpaceMove forward by one screen
Page UpMove backward by one screen
Page DownMove forward by one screen
hShow help for less and its available controls
qQuit the viewer and return to the terminal prompt

For example, after running man ls, press Space or Page Down to continue through the page. Press Page Up to revisit earlier text. If you are unsure about the controls, press h. When finished, press q to leave the manual page.

When the text fills the terminal

If the help text fills the screen and you cannot see the rest, this is expected: the content is being shown through less. Continue with Space or Page Down, or move back with Page Up. If you cannot return to the command prompt, the pager is probably still active; press q.

Finding a command when its name is unknown

Sometimes you know the task but not the command name. In that situation, entering man followed by an unknown name will not help. Use a keyword search instead. A keyword search uses descriptive words to locate relevant documentation.

The -k option tells man to search manual-page names and short descriptions for a keyword:

man -k KEYWORD

For example, suppose you need to remove a print job from a queue, but you do not know which command performs that task. Search for the task-related word cancel:

man -k cancel

The search can return several results. Look at each command name and its short description. One likely result is lprm, a command associated with removing print jobs from a queue. Open its dedicated manual page for complete instructions:

man lprm

The discovery process is therefore:

  1. Describe the task with a relevant keyword.
  2. Run man -k with that keyword.
  3. Compare the returned command names and descriptions.
  4. Select the result that best matches the task.
  5. Run man with that command name to read its full documentation.

Interpreting keyword-search results

A keyword may appear in more than one command name or description, so a search can produce multiple possible matches. Use the command name and its short summary together. A result whose description directly refers to your task is more promising than one that only happens to contain the keyword.

For the print-queue example, an lprm result with a summary about removing print jobs is useful because both the command name and description fit the goal. Confirm its correct usage by opening man lprm before running it.

Ways to get command help

SituationCommand patternExpected result
The command name is knownman COMMANDOpens the manual page for that command
Only a task-related word is knownman -k KEYWORDSearches manual-page names and descriptions and lists possible matches

A complete example

Imagine that you want to learn how to list files:

  1. Open a terminal and enter man ls.
  2. Read the command's purpose and synopsis.
  3. Use Space or Page Down to move forward through the page.
  4. Use Page Up if you need to review an earlier section.
  5. Press h to see less help if you forget a key.
  6. Press q to return to the shell prompt.

If instead you need to remove a queued print job and do not know the command, enter man -k cancel, inspect the matches, and then open the likely result with man lprm.

Quick troubleshooting

  • The help text fills the terminal: It is being displayed by less. Use Space or Page Down to continue and Page Up to go back.
  • You are unsure which keys work: Press h while the manual page is open to display less's help screen.
  • You cannot return to the prompt: The pager is still active. Press q.
  • You know the task but not the command: Search with man -k and a relevant keyword, then read the manual page for a promising result.
  • The search returns several results: Compare their short descriptions, choose the result that matches your task, and verify its exact usage with man COMMAND.

Key points

  • Use local manual pages as the first reference for Linux command usage.
  • Run man COMMAND when you know the command name.
  • Manual pages commonly provide a purpose, synopsis, options, and usage details.
  • Manual pages are normally read interactively with the less pager.
  • Use Space, Page Up, and Page Down to navigate; use h for help and q to quit.
  • Run man -k KEYWORD when you know the task but not the command name.
  • Treat keyword-search results as candidates, then read the selected command's complete manual page.