`help` vs `--help` in Linux: Deciphering the Two
In Linux and Unix-like systems, you often encounter two primary mechanisms for
accessing command documentation right from the terminal: the help
command and
the --help
option. While both serve a similar purpose—providing help and
information about commands—they operate in distinct ways and cater to different
types of commands. This article aims to dissect the differences between these
two, helping you understand when and how to use each.
Exploring --help
Option
The --help
option is a common feature for many executable programs and
external commands in Linux. This option displays a help message with a brief
overview of the command's functionality, its syntax, and options.
Syntax
command_name --help
Example: ls --help
For instance, if you want to know how to use the ls
command and its options,
you would type:
ls --help
This will produce a help message that describes what the ls
command does,
along with a list of options and their descriptions. Unlike help
, the --help
option is usually more concise and may not offer as detailed explanations as man
pages or other sources of documentation.
Table: help
vs --help
Feature | help Command | --help Option |
---|---|---|
Scope | Shell built-ins | External commands/programs |
Syntax | help [option] pattern | command_name --help |
Detail Level | Detailed for built-ins, can offer examples | Usually concise, option-specific |
Flexibility | Offers pattern matching, can list all built-ins | Fixed output, no customization |
Availability | Built into the shell, always available for built-ins | Available if implemented by the command |
Example Use-case | help cd , help -d "c*" | ls --help , grep --help |
When to Use Which?
Use
help
when dealing with shell built-ins: If you need comprehensive information about commands likecd
,echo
,read
, etc., which are built into the shell,help
is your best bet.Use
--help
for external commands: For external programs and utilities likels
,grep
, orwget
, use the--help
option for a quick rundown of available options and basic usage.
Conclusion
Though help
and --help
serve similar end goals, the two are far from
interchangeable. The help
command is specialized for providing detailed
information on shell built-in commands, while the --help
option is designed to
provide a quick overview of external commands and programs. Knowing the
differences between the two will enable you to more effectively seek out
command-line assistance, enriching your Linux command-line experience.
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.