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.
Anatomy of a command
ls -l --all /etc
lsis the command (a program on disk, a shell builtin, a function or an alias).-land--allare options (short and long forms); several short options combine:ls -la./etcis an argument.
Getting help
command --helpprints a summary for most programs.man commandopens the full manual (pressqto quit,/to search).help builtindocuments shell builtins such ascdorread.type nametells you what a name is:
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?
whichtypemaninfo
Show answer
Answer: type
type knows about builtins, functions and aliases; which only searches PATH.