Get Help with Terminal Commands Using man
Learn how to read Linux manual pages with man, navigate them in less, and find unfamiliar Raspberry Pi commands with man -k.
Linux provides many terminal commands. Each command has its own purpose, syntax, options, and flags, so remembering every detail is not realistic. Fortunately, Raspbian and other Linux systems include built-in documentation that you can consult directly from the terminal.
A terminal is a text-based interface where you enter and run commands. A command is a program or shell instruction entered at the prompt. Commands can accept arguments, including options that change or control their behavior. A flag is commonly a short-form option introduced with a hyphen.
For a general introduction to using the Raspberry Pi terminal, see Terminal in Raspbian. You can also review Useful Terminal Commands for more command-line practice.
What Is a Manual Page?
A manual page, often called a man page, is reference documentation for a command, program, or system component. The command named man is short for “manual” and is used to read installed manual pages.
A typical manual page may contain:
- the command name;
- a brief statement of its purpose;
- the invocation or syntax;
- a description of how the command works;
- available options and flags; and
- additional information about its behavior.
Manual pages are useful because they let you check a command before using it instead of guessing what an option does.
Read Documentation for a Known Command
When you know the command name, place it after man. The basic syntax is:
man <command>For example, ls is the command used to list the contents of a directory. To read its documentation, enter:
man lsThis opens the manual page for ls. Look through the page to find its synopsis, description, options, and flags. The documentation is displayed in a pager rather than as ordinary terminal output.
A pager is a program that presents long text one screen or page at a time. The pager typically used for manual pages is less. This means the terminal is temporarily showing a navigable document; it has not stopped responding or become stuck.
Navigate a Manual Page with less
While man ls is open, use the following keys to move through the text:
For example, press Space when you want to advance by one screen. Press Page Up to review earlier material or Page Down to move forward. If you forget the navigation keys, press h to display the help screen. When finished, press q.
Find a Command When You Do Not Know Its Name
Sometimes you know what you want to do but do not know which command performs the task. The man -k form searches the manual-page database using a keyword.
man -k <keyword>The search checks command names and short manual-page descriptions for the supplied keyword. Because the keyword can match several entries, the results may contain multiple related commands. Read the descriptions and choose the entry that best matches your task.
Example: Find the Command for Cancelling Print Jobs
Suppose you need to cancel a print job but do not know the command name. Search the manual-page index with the task keyword:
man -k cancelReview the resulting entries and their short descriptions. The relevant command for removing or cancelling print jobs is lprm.
Do not rely only on the search result. Open the full documentation for the command before using it:
man lprmThe manual page explains the command's purpose, syntax, and available options. This two-step approach is useful whenever you know a task but not the command: search with man -k, then inspect a promising result with man.
Troubleshooting Manual-Page Searches
The page seems impossible to exit
The content is probably open in less. Press q to leave the pager and return to the terminal prompt.
The information is farther down the page
Manual pages are often longer than one terminal screen. Press Space or Page Down to advance. Use Page Up to return to earlier content.
You know the task but not the command
Use a relevant keyword with man -k. For example, man -k cancel searches for manual entries related to cancelling. Then read the result descriptions and open a suitable command with man.
The keyword search returns several commands
This is normal because man -k searches both command names and descriptions. Compare the short descriptions, select the command that matches your task, and read its complete manual page before running it.
Quick Reference
man lsopens documentation for listing directory contents.man -k cancelsearches manual-page names and descriptions for “cancel”.man lprmopens documentation for the command that removes or cancels print jobs.- Use Space for the next page, Page Up for earlier content, and Page Down for later content.
- Press h for
lesshelp and q to quit.