Help in the terminal: man pages, —help and tldr
In short: On Linux and macOS every program explains itself: with man, —help and tldr you find options and examples without opening the browser.
In more detail: There are hundreds of commands with countless options; nobody knows them all. What matters is looking things up quickly. The help is available offline and fits the installed version exactly.
In Depth
—help and -h
The quickest variant: ls --help, git --help, git commit -h. It shows a short overview of options. Some programs use -h, help or /? (Windows). For long output | less helps (scroll, q quits): grep --help | less.
man pages
man ls opens the detailed manual page. Navigation: arrow keys/space bar, /term searches, n jumps to the next match, q quits. Structure: NAME, SYNOPSIS (invocation), DESCRIPTION, OPTIONS, EXAMPLES, SEE ALSO. The number indicates the section: man 1 printf (command), man 3 printf (C function), man 5 passwd (file format). man -k term or apropos term searches manuals on a topic. info sometimes offers more detailed documentation.
tldr and cheat.sh
The man pages are precise but long. tldr (“too long; didn’t read”) shows the most common examples briefly and clearly: tldr tar. Installation: npm install -g tldr, pip install tldr or via package manager. Online: curl cheat.sh/tar. Cheat sheets in this wiki help too.
Other ways
type command,which command,command -v command: where is the program?whatis command: one-line description.- Tab completion shows options and paths.
- Shell history:
history,Ctrl+Rto search earlier commands. - Project documentation (README, website) and forums such as Unix & Linux StackExchange.
Habit: first
--help, thenman, then the web.
See also: grep, sed and awk, zsh, fish and bash, bash, Writing shell scripts