The `help` Command in Linux: Your In-depth Guide to Bash Built-ins
When you're navigating through the Linux terminal, there's a good chance you'll
need help figuring out how to use certain commands. While many external commands
and programs offer a --help option for quick insights into their
functionalities, what about the shell built-in commands? That's where the help
command comes into play. Unlike the --help option, the help command
exclusively serves shell built-ins, providing details about their usage,
options, and more. Let's dive in.
Syntax
The basic syntax for the help command is:
help [option] [command]
[options]is optional flags you can provide to tailor the output,[command]represents the shell built-in command for which you're seeking help.
Exclusivity for Shell Built-ins
The help command is exclusive in nature. It is strictly designed to provide
information about shell built-in commands. These are commands integrated within
the shell itself, such as cd, echo, read, and so forth. If you try to
use help for external commands or programs, it simply won't work.
Options Table
| Option | Shorthand | Description |
|---|---|---|
--detailed | -d | Show a short description for each built-in |
--m | -m | Display built-in help in a manpage-style |
Examples
Using help for the cd Command
The simplest way to use help is to type it followed by the name of the
built-in command you want information on.
help cd
This will produce a detailed description of what the cd command does, along
with the options you can use with it.
Combining help with -d for Multiple Commands
If you want a brief description of several commands, you can use a wildcard *
combined with the -d option.
help -d "c*"
This will output a list of all built-in commands that start with the letter "c", along with a short description of each.
Using help -m for Manpage-style Output
Sometimes, you might prefer viewing the information in a manpage-style format.
This can be accomplished using the -m flag.
help -m cd
This will display the help content for the cd command in a manner similar to a
manpage, making it easier to read and understand.
Conclusion
Understanding the help command is essential for mastering the Linux terminal,
especially when you're dealing with shell built-in commands. This specialized
tool is your go-to for getting insights into how built-in commands work, how
they are to be used, and what options they offer. Its exclusivity for shell
built-ins means you won't find details about external programs or commands, but
when it comes to built-ins, it's the most informative guide you'll find right at
your command line.
What Can You DO Next 🙏😊
If you liked the article, consider subscribing to Cloudaffle, my YouTube Channel, where I keep posting in-depth tutorials and all edutainment stuff for software developers.