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

help [OPTIONS] [PATTERN...]

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

help

Shows a list of all available shell built-in commands with brief descriptions

Get help for specific command

help cd

Displays detailed help information for the cd command

Get help for multiple commands

help cd pwd ls

Shows help for cd, pwd, and ls commands

Show short descriptions

help -d

Displays short descriptions for all built-in commands

Show short description for specific command

help -d export

Shows a brief description of the export command

Display in manpage format

help -m cd

Shows help for cd in pseudo-manpage format

Show only usage synopsis

help -s cd

Displays only the usage synopsis for the cd command

Search for commands by pattern

help '*dir*'

Shows help for commands containing "dir" in their name

Get help for control structures

help if help for help while

Shows help for shell control structures

Help for job control

help jobs help bg help fg

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

Examples of different help systems

help cd # Built-in command help man ls # External command manual info gcc # GNU info documentation grep --help # Quick usage help

See also