help Command
The help command displays information about shell built-in commands. It provides syntax, options, and usage examples for bash built-ins, making it an essential tool for learning shell programming.
Syntax
Description
The help command is a bash built-in that provides documentation for other shell built-in commands. It's the primary way to get help for commands that are part of the shell itself rather than external programs.
Key features:
- Display help for specific built-in commands
- List all available built-in commands
- Search for commands by pattern
- Show brief or detailed help information
- Works only with shell built-in commands
Common Options
| Option | Description |
|---|---|
-d |
Display short description for each command |
-m |
Display usage in pseudo-manpage format |
-s |
Display only short usage synopsis |
Examples
List all built-in commands
Shows a list of all available shell built-in commands with brief descriptions
Get help for specific command
Displays detailed help information for the cd command
Get help for multiple commands
Shows help for cd, pwd, and ls commands
Show short descriptions
Displays short descriptions for all built-in commands
Show short description for specific command
Shows a brief description of the export command
Display in manpage format
Shows help for cd in pseudo-manpage format
Show only usage synopsis
Displays only the usage synopsis for the cd command
Search for commands by pattern
Shows help for commands containing "dir" in their name
Get help for control structures
Shows help for shell control structures
Help for job control
Displays help for job control commands
Common Built-in Commands
| Command | Description |
|---|---|
cd |
Change directory |
pwd |
Print working directory |
export |
Set environment variables |
alias |
Create command aliases |
history |
Command history |
jobs |
List active jobs |
kill |
Terminate processes |
source |
Execute commands from file |
help vs man vs info
When to Use Each
- help - For shell built-in commands (cd, export, alias, etc.)
- man - For external commands and system programs (ls, grep, find, etc.)
- info - For GNU tools with detailed documentation (gcc, emacs, etc.)
- --help - Quick usage information for most commands