Command Line · Lesson 15 of 19
help
0 / 4 checkpoints answered
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.
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.
CheckWhich command displays Bash's help entry for its cd builtin?
press 1/2/3 to answer · → next lesson
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.
CheckWhich command commonly prints a quick usage summary provided by the external ls program?
press 1/2/3 to answer · → next lesson
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.
CheckYou do not know whether deploy is an alias, function, builtin, or executable. Which Bash command checks how the name resolves?
press 1/2/3 to answer · → next lesson
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.
CheckYou need detailed documentation for the external command ls, not only a short usage summary. Which command should you try?
press 1/2/3 to answer · → next lesson
Summary
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.
Lesson complete
You finished help. Nice work — keep the momentum going.