
help Command in Linux
Mastering Linux command-line utilities can be daunting if you are new to Linux. However, there is a solution to this, the help command. As the name suggests, the help command gives you detailed information about other built-in commands in the shell. It's useful for beginners because it helps you understand how commands work, their syntax (how to write them), and their options (different ways to use them).
- The help command shows information about built-in shell commands directly in the terminal. It's a handy tool for quickly learning how to use different commands without leaving the terminal or searching the internet.
- If you're unsure about what a command does or need a quick reminder of how to use it, the help command is there to assist you.
- In addition, the help command is only specific to certain shells, like bash. In zsh, you won't find a built-in help command. Instead, you can use the man command to access the manual pages for commands, or whence to find out how a command is interpreted.
Table of Contents
Here is a comprehensive guide to the options available with the help command −
- Syntax for the help Command
- Options Available for the help Command
- Examples of help Command in Linux
Syntax for the help Command
The following is the general syntax for the help Command −
help [options] [pattern]
Options Available for the help Command
The following are different options you can use with the help command −
Tag | Description |
---|---|
-d | Provides a brief overview of a shell built-in command. Useful when you want a quick summary or short description. |
-m | Displays the usage information in a format similar to a man page (manual page). Useful for detailed information presented in a structured format. |
-s | Provides a short usage synopsis for each topic matching the pattern. Handy for a quick reminder of the command’s syntax. |
--help | Displays help information for the help command itself. Useful when you need to understand how to use the help command. |
Examples of help Command in Linux
In this section, we'll explore some practical examples of using the "help" command in Linux −
Getting Help for a Specific Command
To use the help command for retrieving information about a built-in shell command, simply type the help command followed by the command you want the information. For example, to view the information for the cd command, you can use the following syntax −
help cd

Display Short Description of Shell Built-in Commands
To display a short description of a command's functionality, use the help command with the "-d" flag. For instance, to view the short description for the pwd command, you can use the following syntax −
help -d pwd

Viewing Command Information in Pseudo-Manpage Format
To view information about a command in a pseudo-manpage, you can use the help command with the "-m" flag. For instance, you can use the following command to view the pseudo-manpage format of the exit command −
help -m exit

Viewing Short Synopsis of Shell Built-in Commands
To view the short usage synopsis of a command, you can use the help command with the "-s" flag. For instance, to view the short synopsis for the pwd command, you can use the following syntax −
help -s pwd

Viewing Manpages of Commands Starting with a Specific Letter
You can use the help command with wildcard characters to list commands starting with a specific letter. To achieve this, you can run the following command −
help -m b*
This command displays the manpage-style help for all available commands starting with "b". Itâs a useful way to quickly find and understand the commands you need.

Listing Commands with Matching Patterns
To list commands that follow a matching pattern, you can use the following syntax −
help -d 'b[cz]*'
This command lists all available commands that start with "bc" or "bz". Itâs a useful way to filter commands based on specific starting patterns.

Getting Help for Multiple Commands
To get help information for multiple commands at once, you can run the following command −
help cd mkdir echo
This command displays help information for the cd, echo, and mkdir commands.

Displaying Help for the help Command Itself
To understand how to use the help command, you can simply execute the following command −
help help
This command shows detailed information about the help command, including its options and usage.

Conclusion
To wrap up, the help command is an invaluable resource for anyone navigating the Linux command line, particularly for beginners. It provides quick and accessible information about built-in shell commands, helping users grasp command syntax and options without needing to search external resources.
However, it's essential to note that the help command is limited to built-in shell commands and does not extend to external commands. For external commands, you can rely on the man command or other documentation tools to find the necessary information.
By integrating the help command into your Linux toolkit, you can enhance your command-line proficiency and troubleshoot more effectively as you explore the vast capabilities of the Linux environment.