Where to start First steps track · 15 stages
Linux Labs

Getting help at the terminal

4 min Linux

How to quickly find a command's options: man, --help, apropos and tldr; how to read a man page.

Cheat sheet

7 commands Printable version
  • cmd --help a quick reference
  • man cmd the full manual
  • man 5 cmd a specific manual section
  • man -k topic search commands by topic (run mandb if empty)
  • tldr cmd examples, if available
  • type cmd what it is: alias, function, builtin, file
  • help builtin help for a bash builtin

Overview

You don't need to memorize every flag — you need to know how to find them quickly.

bash
command --help                    # a short reference (fast, works for almost every command)
man command                       # the full manual (navigate like less: /search, q to quit)
tldr command                      # real-world examples (if installed) — often more useful than man

Recipes

2

man

bash
man ls                            # the manual page
man 5 crontab                     # section 5 (file formats) — a name can have several sections
man -f crontab                    # = whatis: which sections exist for this name
man -k password                   # search descriptions (= apropos)
apropos network                   # commands related to a topic
whatis ls                         # a one-line description
sudo mandb                        # rebuild the man index (after installing packages, if apropos is empty)

man sections: 1 commands, 2 syscalls, 3 libraries, 5 file formats/configs, 8 admin commands. man crontab (section 1, the command) is not the same as man 5 crontab (the file format).

Navigating inside man (it's just less): /word to search, n/N for next/previous, g/G for start/end, q to quit.

Other places to look

bash
command -h                        # sometimes used instead of --help
cmd --help | less                 # page through a long reference
info command                      # GNU info (more detail for coreutils)
type command                      # is it an alias, a function, a builtin, or a file? (see which)
help if                           # help for bash BUILTINS (if, for, while, …)
tldr cmd                          # examples, from a separate package
cheat cmd                         # community-maintained cheat sheets, another separate package
zcat /usr/share/doc/pkg/*         # a package's docs (often README/changelog)

Troubleshooting

5

man: the command exists, but there's no page

It might be a bash builtin — try help cmd. Or the package ships no man page — try --help, tldr, info, /usr/share/doc/.

apropos/man -k: "nothing appropriate"

The index hasn't been built. Run sudo mandb, then try again.

The man page is too long, you need one flag

man cmd, then /-X (search for the flag, n for the next match). Or cmd --help | grep -- -X.

You don't remember the command's name, only the task

apropos <topic> / man -k <topic> searches every page's description.

You want help with bash syntax (if/for/test)

Those are shell builtin constructs: help if, help test, man bash (long, but complete).

See also

  • files-basics — Navigation and files — ls, cd, cp, mv, rm, cat, less, head, tail, copy-paste in the terminal.
  • grep — Searching lines by pattern; regular expressions, recursion, context.
Loading…