Skip to content

The man command

The man command shows a command’s manual page: what it does…

The man command shows a command’s manual page: what it does, its options and examples; press q to leave it.

Taught in Intermediate, lesson 17

A practice shell in your browser that behaves like bash on Linux for these commands. Nothing you type leaves the page.

Usage

man COMMAND

Show the manual page for a command. Shows how a command works and the options it accepts. Most commands also print a short version of the same with --help.

How to use man

Read a manual page

On a real system the page opens in a pager like less, so Space scrolls and /word searches.

man grep
GREP(1)

NAME
       grep - print lines that match a pattern

SYNOPSIS
       grep [OPTION]... PATTERN [FILE]...

DESCRIPTION
       Searches each file (or what is piped into it) and prints the
       lines that contain PATTERN. The pattern is a basic regular
       expression: plain words work as you would expect, . matches any
… and 50 more lines

A short summary: --help

Most commands also print a short list of their options with --help.

sort --help
Usage: sort [OPTION]... [FILE]...
Sort lines of text.

  -n, --numeric-sort      sort by the number at the start of each line, so 9 comes before 10
  -h, --human-numeric-sort  sort sizes like 4.0K, 12M and 2.1G (what du -h prints) by their real size
  -r, --reverse           reverse the order
  -u, --unique            print each distinct line once
  -f, --ignore-case       treat upper and lower case as the same when comparing
  -k N                    sort by the Nth word of each line instead of the whole line

Full manual: man sort

Every command here: help

In the practice shell, help lists all the commands it knows.

help
Commands in this practice shell:

  adduser      create a user the friendly way (Debian and Ubuntu)
  alias        make a short name for a longer command
  apt          install, remove and search for software (Ubuntu and Debian)
  apt-get      the older apt, still used in scripts
  awk          scan text for patterns and work with its columns
  basename     strip the folders (and a suffix) from a path
  bash         the shell: run commands and scripts
  bg           let a paused job carry on in the background
  break        leave a loop early
  cat          print the contents of files
… and 146 more lines

Questions about man

How do I search inside a man page?

Type / followed by the word and press Enter; n jumps to the next match. Press q to quit.

Learn it step by step

Every everyday command on one page, to print or keep open: the Linux commands cheat sheet.