You do not need to memorize every command option. Bash and many installed programs can explain their syntax directly in the terminal, but the right help source depends on what kind of command you are using.
Command Line · Lesson 15
help
Learn how to choose built-in help, program usage output, or manual pages for a command.
Getting Help for Bash Builtins
Bash provides the help builtin for commands implemented by the shell itself. Examples include cd, history, and type.
Pass the builtin name as an argument:
$ help echo
The output describes the builtin's syntax and behavior. Running help without an argument lists the builtins for which Bash has help.
Which command displays Bash's help entry for its cd builtin?
Requesting a Program's Usage Summary
Many external programs follow the convention of accepting --help and printing a usage summary:
$ ls --help
This convention is common but not universal. Read the output and exit status rather than assuming every program supports the same option.
Which command commonly prints a quick usage summary provided by the external ls program?
Finding How Bash Resolves a Name
Use type to see whether Bash resolves a name as a builtin, alias, function, keyword, or executable file:
$ type cd
cd is a shell builtin
$ type ls
ls is /usr/bin/ls
The exact result can vary with aliases, functions, installed programs, and PATH. Use type -a NAME when you want Bash to show all known resolutions rather than only the one it would use first.
You do not know whether deploy is an alias, function, builtin, or executable. Which Bash command checks how the name resolves?
Choosing the Level of Detail
- Use
help COMMANDfor a Bash builtin. - Use
COMMAND --helpfor a quick summary from many external commands. - Use
man COMMANDfor an installed manual page with more detailed documentation. - Use
whatis COMMANDfor a one-line description.
The next lessons examine manual pages and one-line descriptions in more detail.
You need detailed documentation for the external command ls, not only a short usage summary. Which command should you try?
Lesson complete
You finished help
You can now choose a help source based on how Bash resolves a command.
Use
helpfor Bash builtins.Try
--helpfor a program's quick usage output.Inspect name resolution with
type.Open detailed documentation with
man.
Keep your learning progress
Create a free account to save this lesson and continue learning on any device.
Create a free account