Bash Tutorial · Bash Basics · Lesson 3 of 30

Bash Commands and Getting Help

How commands, options and arguments work, and how to find help with --help, man and type.

Create a free account to save this page, take notes and track your progress. Sign in

Anatomy of a command

ls -l --all /etc
  • ls is the command (a program on disk, a shell builtin, a function or an alias).
  • -l and --all are options (short and long forms); several short options combine: ls -la.
  • /etc is an argument.

Getting help

  • command --help prints a summary for most programs.
  • man command opens the full manual (press q to quit, / to search).
  • help builtin documents shell builtins such as cd or read.
  • type name tells you what a name is:
Builtins, programs and help
type cd
type ls | sed 's/(.*//'
type -t echo
wc --help | head -n 2
help cd | head -n 1

Output

cd is a shell builtin
ls is /usr/bin/ls
builtin
Usage: wc [OPTION]... [FILE]...
  or:  wc [OPTION]... --files0-from=F
cd: cd [-L|[-P [-e]] [-@]] [dir]

Run this on your computer — see “Get Started” for setup.

Test yourself

Which command tells you whether a name is a builtin, a program or an alias?

  1. which
  2. type
  3. man
  4. info
Show answer

Answer: type

type knows about builtins, functions and aliases; which only searches PATH.

Was this page helpful?