Skip to lesson

Linux Command Line · Lesson 4 of 43

Getting help with man, --help and type

Learn to get help for any Linux command using man pages, the --help flag, type, which, apropos and info, and how to read a manual page.

Beginner to intermediate·12 min·Getting started·Updated 2026-11-24

UNDERSTAND IT. THEN TRY IT.

What you can do after this lesson

No one remembers every option of every command, and nobody is expected to. Experienced users look things up many times a day. In this lesson you learn the fastest ways to do that, so that you can always teach yourself the next command.

--help: the quick answer

Most commands print a short summary when you add --help. It is fast and works inside the same window:

bash
mkdir --help | head -n 6
result
Usage: mkdir [OPTION]... DIRECTORY...
Create the DIRECTORY(ies), if they do not already exist.

Mandatory arguments to long options are mandatory for short options too.
  -m, --mode=MODE   set file mode (as in chmod), not a=rwx - umask
  -p, --parents     no error if existing, make parent directories as needed

We added | head -n 6 to show only the first lines. The pipe | is explained in a later lesson; for now, it limits the output so it fits on screen. On macOS, many commands print usage after you give them a wrong option instead of accepting --help.

man: the full manual

man (manual) shows the complete documentation of a command in a pager, a viewer that lets you scroll:

text
man ls

Inside the page:

  • Space or f scrolls down a page, b scrolls up.
  • /word searches forward; n goes to the next match, N to the previous.
  • q quits and returns to the prompt.

Pages are divided into sections with the same names every time. Read these first:

  • NAME: the command and a one-line description.
  • SYNOPSIS: the shapes the command line can take.
  • DESCRIPTION and OPTIONS: the details.
  • EXAMPLES, when present, and SEE ALSO, which points to related commands.

Servers and containers sometimes do not install man pages to save space. In that case rely on --help, or read the manual online.

Reading a synopsis

The synopsis is a compact grammar. For example, the synopsis of cp includes lines like this:

text
cp [OPTION]... SOURCE... DIRECTORY

Read it as: the command cp, then zero or more options (square brackets mean optional, the three dots mean repeatable), then one or more sources, then a directory. A vertical bar means "one or the other". Words in capitals are placeholders that you replace with real values.

type and which: what is this name?

When you type a name, the shell must decide what it refers to. type tells you:

bash
type cd
type ls
type pwd
result
cd is a shell builtin
ls is /usr/bin/ls
pwd is a shell builtin

A builtin is part of the shell itself. A file result means a separate program found on disk, and the path shows where. An alias is a shortcut defined in your shell; you will create some later.

Use -a to list every match, and which to print only the path of a program:

bash
which ls
result
/usr/bin/ls

The exact path differs between distributions, and some systems show /bin/ls and others /usr/bin/ls. On many desktop and server installs ls and grep are also aliases that add colour in an interactive shell, so type ls may print a line such as ls is aliased to `ls --color=auto' instead. Both answers are normal; type -a ls shows every match. Builtins have their own help: help cd prints it.

apropos: finding a command by what it does

When you do not know the command name, search the one-line descriptions with apropos, or equivalently man -k:

text
apropos "copy files"

This lists manual pages whose summary matches. It needs the manual database to be installed, so it may print nothing on minimal systems.

info and other sources

Some GNU tools have longer documentation in info, a hyperlinked format. Many projects also ship examples in /usr/share/doc. Online, the best sources are the project's own documentation, your distribution's wiki and community answers; always check that the command matches your distribution and version.

Common mistakes

Searching the web before reading the man page. Man pages match your installed version exactly, which online answers might not.

Getting stuck in a man page. Press q. Ctrl+C does not always work in a pager.

Assuming macOS and Linux options are identical. sed -i, date -d and ls --color behave differently on macOS. The manual of your own system is the truth.

Running a command you do not understand. Read what each option does first, especially with rm, chmod, dd and anything run with sudo.

Exercise

Run type on cd, echo and grep and note which are builtins. Run grep --help | head -n 15. If man pages are installed, open man ls, search for human-readable using /, then quit. Finally, use man -k or apropos to find a command that "sorts" something.

KNOWLEDGE CHECK

A quick check. You’ve got this.

Try each question. Every answer comes with an explanation.

0 / 4 understood
01 Which command opens the full manual of ls?
02 How do you leave a man page?
03 What does type cd tell you on Bash?
04 In a synopsis, what does [OPTION]... mean?

Ready for the next small win?

Mark the lesson complete when you are ready.

Course navigation

Tools and Workflow

Linux Command Line tutorial

Learn to work confidently in the terminal, from your first command to pipes, permissions, scripts and a real log-analysis project.

Your progress 0/43
Learning something new?Explore all courses