Kahibaro
Discord Login Register

2.1.5 Getting help

Using Built In Help on the Command Line

When you start working in a Linux terminal, you do not need to remember every command or option. The system provides several built in ways to discover, read, and explore help. This chapter focuses on those tools and how to use them effectively.

Using `--help` with Commands

Many commands provide a short help message when you add the --help option. This works especially often with GNU tools.

You usually run it like this:

command --help

For example:

ls --help
cp --help
grep --help

The output is typically a brief description, usage syntax, and a list of common options. It is meant for quick reference, not long reading sessions.

Some commands support -h instead of or in addition to --help. For example:

tar -h or tar --help

If -h shows something unrelated, such as “human readable sizes,” check --help instead.

Remember: --help is fast and informal. For complete documentation, use man or info.

Manual Pages with `man`

The man program displays the system manuals. Each manual entry is called a man page. Man pages are organized by sections, for example user commands, system calls, configuration files, and more. As a beginner you will mostly see user command pages.

To read the man page for a command:

man ls
man cp
man grep

Inside man, you are in a pager program, often less. Basic keys:

Up and Down arrows to scroll line by line.
Page Up and Page Down to scroll by pages.
q to quit and return to the shell.
/word to search forward for word.
n to jump to the next search match.
N to jump to the previous match.

For example, if you want to search inside the ls man page for “color”, type:

/color then press Enter.
Then press n to move to the next occurrence of “color”.

Many commands exist in several sections. You can specify the section explicitly:

man 1 passwd to see the user command.
man 5 passwd to see the file format for /etc/passwd.

If you do not know which man page contains a topic, but you know a keyword, you can search by keyword. The next section describes that.

Searching Documentation with `man -k` and `apropos`

Sometimes you remember what you want to do, but not the exact command name. The manual index can help. Two tools use that index, man -k and apropos. They are very similar.

To search for a word in man page names and short descriptions, use:

man -k keyword

or

apropos keyword

For example:

man -k copy
apropos network

This shows a list of entries where the name or brief description matches the keyword. Each line shows something like:

cp (1) - copy files and directories

From there, you can open a specific page:

man 1 cp

If man -k or apropos gives no results, your manual index may be out of date. Some systems provide a command like mandb that rebuilds the index. The exact command depends on your distribution and will be discussed elsewhere when you learn more about system administration.

Reading Info Pages with `info`

Some software packages use the GNU Info system for their full manuals. man pages are usually shorter and reference style. info manuals can be longer and more tutorial style.

To open an info manual for a command:

info coreutils 'ls invocation'
info ls

If there is a dedicated info manual for ls, info ls will show it. If not, it may redirect you to a broader manual such as coreutils.

Inside info, you navigate like this:

Space to move forward.
Backspace to move backward.
n for next node.
p for previous node.
u to go up one level.
q to quit.

On many modern systems man pages are enough for most tasks. Info manuals become more useful when you want deep details, such as in development tools or programming libraries.

Finding Which Command to Use

If you know part of a command name but not the full name, you can use shell completion or the which family of tools. Completion and history are discussed elsewhere. Here we focus on discovery with help tools.

You can use man keyword search, as above, or another manual search tool like:

whatis ls

This gives a one line summary of the manual entry, similar to one apropos result, but only if you know the exact name.

When you are exploring an unfamiliar toolset, it is useful to look at the index of all manuals with a pattern:

man -k ^ssh

Here ^ssh is a regular expression that matches all man pages whose names start with ssh. This can show many SSH related commands at once.

Online Help and `--version`

Many distributions include documentation that links to online manuals, wikis, and forums. From the command line, you often see URLs at the end of --help output or inside man pages. These URLs usually lead to an official website or documentation portal that provides examples and guides.

For example:

bash --help
bash --version

These often include a homepage link where you can read more. --version usually shows the program version and copyright information, and sometimes a web address.

You can copy such a URL and open it in a web browser to access more detailed, sometimes more beginner friendly documentation and tutorials.

Local help tools like man and --help always match the version installed on your system. Online documentation may describe a newer or older version. If the behavior is different, check your local man page to confirm what your version supports.

Learning to Read Help Efficiently

At first, man pages and help output can feel dense. With practice, you can scan them quickly.

You can use this practical routine:

  1. Run command --help to get a short overview and see the most common options.
  2. If you need more explanation, run man command.
  3. Inside man, search for a specific word with /your_word and move through matches with n.
  4. If you do not know the right command, use man -k keyword or apropos keyword to discover candidates.

By combining these tools, you can figure out unfamiliar commands on your own and build confidence in working with the terminal.

Views: 67

Comments

Please login to add a comment.

Don't have an account? Register now!