|

Linux CLI 8 ๐Ÿง help, –help and man

These three tools help you learn how to use commands โ€” from quick built-in help to full documentation manuals. Knowing how to use them is essential for becoming self-sufficient on the command line.


Overview

ToolPurposeBest For
helpHelp for bash builtinsBuilt-in commands like cd, echo
--helpQuick help for external commandsMost command-line tools
manFull manual pagesDetailed documentation

The help Command

The help command displays information about bash built-in commands.

help
help cd
help -d cd
help -s cd
help -m cd
CommandDescription
helpList all bash builtins
help cdShow help for the cd builtin
help -d cdShow a short description
help -s cdShow a short synopsis
help -m cdDisplay help in pseudo-manpage format

Examples

List all builtins:

$ help
GNU bash, version 5.1.16(1)-release (x86_64-pc-linux-gnu)
These shell commands are defined internally.  Type `help' to see this list.
Type `help name' to find out more about the function `name'.
Use `info bash' to find out more about the shell in general.
Use `man -k' or `info' to find out more about commands not in this list.

A star (*) next to a name means that the command is disabled.

 job_spec [&]                            history [-c] [-d offset] [n] ...
 (( expression ))                        if COMMANDS; then COMMANDS; ...
 . filename [arguments]                  jobs [-lnprs] [jobspec ...] ...
 :                                       kill [-s sigspec | -n signum ...
 [ arg... ]                              let arg [arg ...]
 [[ expression ]]                        local [option] name[=value] ...
 alias [-p] [name[=value] ... ]          logout [n]
 bg [job_spec ...]                       mapfile [-d delim] [-n count] ...
 bind [-lpsvPSVX] [-m keymap] ...       popd [-n] [+N | -N]
 break [n]                               printf [-v var] format [arguments]
 builtin [shell-builtin [arg ...]]       pushd [-n] [+N | -N | dir]
 caller [expr]                           pwd [-LP]
 case WORD in [PATTERN [| PATTERN]...)   read [-ers] [-a array] ...
 cd [-L|[-P [-e]] [-@]] [dir]            readarray [-d delim] [-n count] ...
 command [-pVv] command [arg ...]        readonly [-aAf] [name[=value] ...]
 compgen [-abcdefgjksuv] [-o option] ... return [n]
 complete [-abcdefgjksv] [-pr] ...       select NAME [in WORDS ... ;] do ...
 compopt [-o|+o option] [-DEI] [name ...]  set [-abefhkmnptuvxBCEHPT] ...
 continue [n]                            shift [n]
 coproc [NAME] command [redirections]    shopt [-pqsu] [-o] [optname ...]
 declare [-aAfFgiIlnrtux] [-p] ...      source filename [arguments]
 dirs [-clpv] [+N] [-N]                  suspend [-f]
 disown [-h] [-ar] [jobspec ... | pid ...]  test [expr]
 echo [-neE] [arg ...]                   time [-p] pipeline
 enable [-a] [-dnps] [-f filename] ...  times
 eval [arg ...]                          trap [-lp] [[arg] signal_spec ...]
 exec [-cl] [-a name] [command ...]     true
 exit [n]                                type [-afptP] name [name ...]
 export [-fn] [name[=value] ...] ...    typeset [-aAfFgiIlnrtux] [-p] ...
 false                                   ulimit [-SHabcdefiklmnpqrstuvxPT] ...
 fc [-e ename] [-lnr] [first] [last] ... umask [-p] [-S] [mode]
 fg [job_spec]                           unalias [-a] name [name ...]
 for NAME [in WORDS ... ] ; do COMMANDS; done  unset [-f] [-v] [-n] [name ...]
 for (( exp1; exp2; exp3 )); do COMMANDS; done  until COMMANDS; do COMMANDS; done
 function name { COMMANDS ; } or name () { COMMANDS ; }  variables - Names and meanings of ...
 getopts optstring name [arg ...]        wait [-fn] [-p var] [id ...]
 hash [-lr] [-p pathname] [-dt] [name ...] while COMMANDS; do COMMANDS; done
 help [-dms] [pattern ...]               { COMMANDS ; }

Help for a specific builtin:

$ help cd
cd: cd [-L|[-P [-e]] [-@]] [dir]
    Change the shell working directory.

    Change the current directory to DIR.  The default DIR is the value of the
    HOME shell variable.

    Options:
      -L        force symbolic links to be followed: resolve symbolic
                links in DIR after processing instances of `..'
      -P        use the physical directory structure without following
                symbolic links: resolve symbolic links in DIR before
                processing instances of `..'
      ...

Short description (-d):

$ help -d cd
cd - Change the shell working directory.

Short synopsis (-s):

$ help -s cd
cd: cd [-L|[-P [-e]] [-@]] [dir]

Pseudo-manpage format (-m):

$ help -m cd
NAME
    cd - Change the shell working directory.

SYNOPSIS
    cd [-L|[-P [-e]] [-@]] [dir]

DESCRIPTION
    Change the current directory to DIR.
    ...

When to Use help

Use help for…Example
Shell builtinshelp cd, help echo
Bash-specific commandshelp declare, help local
Checking builtin optionshelp -m read

Note: help only works for bash builtins โ€” not for external commands like ls or cp. For those, use --help or man.


The --help Option

Most commands support the --help option โ€” a common command-line argument that displays help information.

cp --help
cp --help | less
CommandDescription
cp --helpShow help for the cp command
cp --help | lessShow help one screen at a time
ls --helpHelp for ls
grep --helpHelp for grep

Examples

$ cp --help
Usage: cp [OPTION]... [-T] SOURCE DEST
  or:  cp [OPTION]... SOURCE... DIRECTORY
  or:  cp [OPTION]... -t DIRECTORY SOURCE...
Copy SOURCE to DEST, or multiple SOURCE(s) to DIRECTORY.

Mandatory arguments to long options are mandatory for short options too.
  -a, --archive                same as -dR --preserve=all
      --attributes-only        don't copy the file data, just the attributes
      --backup[=CONTROL]       make a backup of each existing destination file
  -b                           like --backup but does not accept an argument
      --copy-contents          copy contents of special files when recursive
  -d                           same as --no-dereference --preserve=links
  -f, --force                  if an existing destination file cannot be
                                 opened, remove it and try again (this option
                                 is ignored when the -n option is also used)
  -i, --interactive            prompt before overwrite (overrides a previous -n
                                 option)
  -H                           follow command-line symbolic links in SOURCE
  -l, --link                   hard link files instead of copying
  -L, --dereference            always follow symbolic links in SOURCE
  -n, --no-clobber             do not overwrite an existing file (overrides
                                 a previous -i option)
  -P, --no-dereference         never follow symbolic links in SOURCE
  -p                           same as --preserve=mode,ownership,timestamps
      --preserve[=ATTR_LIST]   preserve the specified attributes (default:
                                 mode,ownership,timestamps), if possible
                                 additional attributes: context, links, xattr,
                                 all
      --no-preserve=ATTR_LIST  don't preserve the specified attributes
      --parents                use full source file name under DIRECTORY
  -R, --recursive              copy directories recursively
      --reflink[=WHEN]         control clone/CoW copies. See below
      --remove-destination     remove each existing destination file before
                                 attempting to open it (contrast with --force)
      --sparse=WHEN            control creation of sparse files. See below
      --strip-trailing-slashes  remove any trailing slashes from each SOURCE
                                 argument
  -s, --symbolic-link          make symbolic links instead of copying
  -S, --suffix=SUFFIX          override the usual backup suffix
  -t, --target-directory=DIRECTORY  copy all SOURCE arguments into DIRECTORY
  -T, --no-target-directory    treat DEST as a normal file
  -u, --update                 copy only when the SOURCE file is newer
                                 than the destination file or when the
                                 destination file is missing
  -v, --verbose                explain what is being done
  -x, --one-file-system        stay on this file system
  -Z                           set SELinux security context of destination
                                 file to default type
      --context[=CTX]          like -Z, or if CTX is specified then set the
                                 SELinux or SMACK security context to CTX
      --help     display this help and exit
      --version  output version information and exit
  ...

Piping to less for long output:

$ cp --help | less
# Now you can scroll with โ†‘/โ†“, PgUp/PgDn, q to quit

Why this matters: Some commands have hundreds of lines of help. Piping to less lets you read it comfortably.


When to Use --help

Use --help for…Example
External commandscp --help, ls --help
Quick referenceWhen you need a quick reminder of options
Common toolsMost GNU/Linux tools support it
Piping to lesscommand --help | less for long output

Note: --help is not universal โ€” some commands use -h, -help, or nothing. When in doubt, try man.


The man Command

The man command displays the manual pages for commands and system functions.

man ls
man 2 mkdir
man -f mkdir
man -w mkdir
man -a write
CommandDescription
man lsFull manual for ls
man 2 mkdirManual from section 2 for mkdir
man -f mkdirShort description
man -w mkdirLocation of the man page
man -a writeShow all sections for write

Manual Sections

Manual pages are organized into sections (usually 1โ€“9):

SectionContentExample
1User commandsls, cp, grep
2System calls (kernel)open, read, write
3Library functionsprintf, malloc
4Special files (devices)/dev/null, /dev/tty
5File formats/etc/passwd, fstab
6Gamesโ€”
7Miscellaneousman, regex, signal
8System administrationmount, fdisk, systemctl
9Kernel routinesโ€”

Why sections matter: The same name can mean different things in different sections.

$ man mkdir       # Section 1 โ€” the command
$ man 2 mkdir     # Section 2 โ€” the system call
$ man 3 printf    # Section 3 โ€” the library function
$ man 1 printf    # Section 1 โ€” the command

Common man Options

OptionDescription
-fShow short description (like whatis)
-wShow location of the man page
-aShow all sections (in order)
-kSearch descriptions (keyword search)
-SRestrict to specific sections
-PUse a specific pager

Examples

Basic manual:

$ man ls
LS(1)                       User Commands                       LS(1)

NAME
       ls - list directory contents

SYNOPSIS
       ls [OPTION]... [FILE]...

DESCRIPTION
       List  information  about  the FILEs (the current directory by
       default).  Sort entries alphabetically if none of -cftuvSUX nor
       --sort is specified.

       Mandatory arguments to long options are mandatory for short
       options too.

       -a, --all
              do not ignore entries starting with .

       -A, --almost-all
              do not list implied . and ..
       ...

Short description:

$ man -f mkdir
mkdir (1)            - make directories
mkdir (2)            - create a directory

Find location:

$ man -w mkdir
/usr/share/man/man1/mkdir.1.gz

$ man -w 2 mkdir
/usr/share/man/man2/mkdir.2.gz

All sections:

$ man -a write
# Shows write(1), then write(2), then write(3) โ€” all sections

Keyword search:

$ man -k copy
cp (1)               - copy files and directories
cpio (1)             - copy files to and from archives
dd (1)               - convert and copy a file
install (1)          - copy files and set attributes
...

Navigating man Pages

The man command uses less as its pager. Here are the navigation shortcuts:

KeyAction
SpaceOne screen ahead
bOne screen back
EnterOne line ahead
โ†‘ / โ†“Line up / down
gGo to beginning
GGo to end
/searchTermSearch ahead
nNext occurrence
NPrevious occurrence
hHelp (more shortcuts)
qQuit

Examples:

$ man ls
# Press /recursive to search for "recursive"
# Press n to find next occurrence
# Press h to see help
# Press q to quit

Complete Example Session

# ============================================
# PART 1: HELP COMMAND (BUILTINS)
# ============================================

# List all builtins
$ help
# (long list of builtins)

# Help for a specific builtin
$ help cd
cd: cd [-L|[-P [-e]] [-@]] [dir]
    Change the shell working directory.
    ...

# Short description
$ help -d cd
cd - Change the shell working directory.

# Short synopsis
$ help -s cd
cd: cd [-L|[-P [-e]] [-@]] [dir]

# Pseudo-manpage format
$ help -m cd
NAME
    cd - Change the shell working directory.
...

# ============================================
# PART 2: --help (EXTERNAL COMMANDS)
# ============================================

# Quick help for cp
$ cp --help
Usage: cp [OPTION]... [-T] SOURCE DEST
...

# Pipe long help to less
$ cp --help | less
# (scrollable)

# Help for ls
$ ls --help
Usage: ls [OPTION]... [FILE]...
...

# ============================================
# PART 3: MAN (FULL DOCUMENTATION)
# ============================================

# Manual for ls
$ man ls
LS(1)                    User Commands                    LS(1)

NAME
       ls - list directory contents
...

# Specific section
$ man 2 mkdir
MKDIR(2)              Linux Programmer's Manual              MKDIR(2)

NAME
       mkdir - create a directory
...

# Short description
$ man -f mkdir
mkdir (1)            - make directories
mkdir (2)            - create a directory

# Location of man page
$ man -w mkdir
/usr/share/man/man1/mkdir.1.gz

# All sections
$ man -a write
# (shows write(1), write(2), etc.)

# Keyword search
$ man -k copy
cp (1)               - copy files and directories
cpio (1)             - copy files to and from archives
...

# ============================================
# PART 4: NAVIGATION IN MAN
# ============================================

$ man ls
# Press Space โ†’ next screen
# Press b โ†’ previous screen
# Press /recursive โ†’ search for "recursive"
# Press n โ†’ next occurrence
# Press h โ†’ help
# Press q โ†’ quit

Quick Reference

help Commands

CommandDescription
helpList all builtins
help nameFull help for a builtin
help -d nameShort description
help -s nameShort synopsis
help -m nameManpage format

--help Option

CommandDescription
cmd --helpQuick help for external command
cmd --help | lessScrollable help

man Commands

CommandDescription
man cmdFull manual
man N cmdSection N manual
man -f cmdShort description
man -w cmdLocation of man page
man -a cmdAll sections
man -k keywordSearch by keyword

man Navigation

KeyAction
SpacePage forward
bPage back
/termSearch
n / NNext / previous match
hHelp
qQuit

Which Tool to Use

SituationUse
Shell builtinhelp name
Quick referencecmd --help
External commandman cmd
Multiple sectionsman -a cmd
Search by keywordman -k keyword
See what sectionman -f cmd
Find the man pageman -w cmd

Best Practices

โœ… Do This:

# Use help for builtins
help cd

# Use --help for quick reference on external commands
cp --help | less

# Use man for full documentation
man cp

# Search within man pages
man ls
# then press /recursive

# Use man -k to discover commands
man -k "copy files"

# Check multiple sections
man -a write

# Use -f to find the right section
man -f mkdir

โŒ Don’t Do This:

# Don't use help for external commands
help ls                # โŒ Won't work

# Don't forget to pipe long help to less
cp --help              # โš ๏ธ Floods your terminal
cp --help | less       # โœ… Better

# Don't skip sections when a name appears in multiple sections
man mkdir              # Might not be the one you want
man 2 mkdir            # โœ… Specific section

# Don't forget to quit man
man ls
# Press q to quit โ€” don't just close the terminal!

Common Pitfalls

PitfallProblemSolution
Using help for external commandsNo outputUse --help or man
Long --help outputFloods terminalPipe to less
Wrong section in manShows wrong pageUse man N cmd
Can’t quit manStuck in pagerPress q
Not finding a commandWrong nameUse man -k keyword

Real-World Examples

1. Learning a New Command

# Start with --help for quick overview
tar --help | less

# Then read the man page for details
man tar

# Search for a specific option
man tar
# press /--extract

2. Finding the Right Command

# Search man pages by keyword
man -k "find files"
# Returns: find(1), locate(1), mlocate(1), ...

# Choose and read
man find

3. Understanding a Builtin

# help for builtins
help read

# For more on read:
help -m read | less

4. Finding Which Section to Use

# Multiple sections match "mkdir"
man -f mkdir
mkdir (1)  - make directories
mkdir (2)  - create a directory

# Read section 1
man 1 mkdir

5. Quick Reference While Working

# In the middle of a task, need cp options
cp --help | grep preserve
# Shows:
# -p   same as --preserve=mode,ownership,timestamps
#      --preserve[=ATTR_LIST]   preserve the specified attributes

Visual: Which Tool for What

โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”
โ”‚  You want to learn about a command...       โ”‚
โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ฌโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜
                   โ”‚
         โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ดโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”
         โ”‚                   โ”‚
    Is it a builtin?    Is it external?
         โ”‚                   โ”‚
         โ–ผ                   โ–ผ
    โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”        โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”
    โ”‚  help   โ”‚        โ”‚  --help  โ”‚
    โ”‚  name   โ”‚        โ”‚  (quick) โ”‚
    โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜        โ””โ”€โ”€โ”€โ”€โ”€โ”ฌโ”€โ”€โ”€โ”€โ”˜
                             โ”‚
                             โ”‚ Need more detail?
                             โ–ผ
                       โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”
                       โ”‚   man   โ”‚
                       โ”‚  name   โ”‚
                       โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜

Summary

CommandPurposeExample
helpHelp for bash builtinshelp cd
--helpQuick help for external commandscp --help
manFull manual pagesman cp

Key takeaways:

  • help works only for bash builtins โ€” use help -d, -s, -m for different formats
  • --help is a common option for external commands โ€” pipe to less for long output
  • man provides complete documentation organized into 9 sections
  • Use man -f to find the right section, man -w to find the file, man -k to search
  • Navigate man pages with Space, b, /search, n, h, q

Remember: You don’t need to memorize every command and option. The three tools โ€” help, --help, and man โ€” let you look up what you need when you need it. Use them liberally โ€” they’re your built-in reference manual for the entire system!


Stop using slow, ad-bloated tool sites! ๐Ÿคฎ

๐Ÿ”Ž Search “KandZ Tools” on Google to use many professional utilities for free.

KandZ.me is the ultimate minimalist hub for:
โœ… Finance (Mortgage, Interest, Inflation)
โœ… Tech (Base64, JSON, Dev Suite, IP)
โœ… Health (BMI, BMR, TDEE)
โœ… Productivity (Timer, Workspace, QR)

โšก๏ธ Fast & Private
๐Ÿ”’ No data leaves your device
๐Ÿ’Ž 100% Free

๐Ÿ”— Use it now: https://tools.kandz.me
๐Ÿ”– Bookmark itโ€”youโ€™ll need it later!