Updated April 18, 2023
Introduction to Linux Help Command
Any computer operating system or application or software we use has a help tab that contains an inbuilt guide regarding the particular application which is helpful to the users. Likewise, Linux which is based on command-line utilities also comes up with some helpful options. If someone is using Linux for the first time or having some confusion during their session, one can always use the help option to solve their queries.
What is Help Command?
Before using the help command, we should know what is help command. To be precise help command displays information about the built-in commands present in the Linux shell.
$ help [-dms] [pattern...]
Here the pattern specifies the command for which we need help. If the input provided by us matches with any of the built-in shell commands then the help command displays details about that and if the input is not matched then it displays a synopsis of help topics that the user can choose from. Here d, m, and s are options used with the help command.
To get a clear picture of the help command, use the following command.
$ help help
This command displays the page which contains the information about the help command itself.
Options Used in Help Command
d, m, and s are the options used with the help command.
1. -d Option
This option is used in cases when we just need to get an overview of any command built in the shell which means this option just gives a brief description of a command like what it does without providing any details of the options.
$ help -d
2. -m Option
This option displays the output in pseudo-manpage format.
$ help -m
3. -s Option
This option displays only the syntax of a particular command.
$ help –s
$ help echo
This command will print a short description of the echo command.
Using Help Command with Options
let us consider the command cd. To display the entire information about the cd command passes the string cd as a parameter to the help command.
$ help cd
To display all the available information about the cd command -m option is used. This is similar to the man command.
$ help –m cd
When you compare the above output with the previous output you can note the difference between both the command outputs. when -m option is not used the output is displayed in an ordinary text format. when the -m option is used with the help command the output is displayed in sections. The man command aligns the information in sections.
suppose you don’t want a full description of the cd command, but you want to know only what the command cd does, then use the option -d.
$ help -d cd
The following output is produced in the system.
It can be seen that when -d option is used with the help command, the output displayed contains a short description of what the particular command does.
If you want to know about using the cd command or the syntax of the command you can use the –s option.
$ help –s cd
Getting Help About Internal and External Commands
There are two types of commands in a Linux shell: External commands and internal commands. Internal commands are those built-in the shell. They will be automatically installed while installing the shell. so most of the internal commands doesn’t install any distinct documentation.
The help command can be used only to get help about the internal command. It cannot be used for external commands. If you provide an external command as a parameter to the help command then the output will display the error message as shown below.
For instance, if we provide password command as the parameter for the help command then you will see the error message as shown below.
To find out whether a given command is internal or external we have to use which command. The command displays the information about the location of the command which is specified. We know that internal commands are a part of the Linux shell and they will be directly executed from the shell. Hence, if the input command is internal then the which command won’t produce any output. If the command specified is an external one, then the installation path of the specified command will be displayed by the which command.
To view, all the internal commands use the following command line.
$ compgen -b | column
The external command comes with the packages. They will be installed along with their respective packages. Normally when a Linux package instates an external command, it will also install documentation about that command.
Other Ways to Get Help on The Linux Shell
Using Tab Completion: If we are not sure about the accurate name of a certain command then we can use the tab completion. Start the terminal by using Ctrl + Alt + T or by clicking the terminal icon present in the taskbar. Now enter the command that you want to know and then hit tab twice and the output is produced as shown below.
Using Unknown Command: If you wanna use a particular command but you are not sure whether the command is installed in the Linux shell or even if it exists you don’t know which package contains it, you can still use the command. Start the terminal by using Ctrl + Alt + T or by clicking the terminal icon present in the taskbar. Now enter the command that you want to check and then press enter. The output will be displayed which will tell whether the command is installed in the shell or not. If the command is displayed then the output will tell the package in which the command exists.
The Info Command: This command is used to get help for commands which don’t contain manuals or contains incomplete manuals.
Example: info bash
Whatis Command: This command provides the one-line description of the specified command without providing the entire manual.
$ whatis [command name]
We hope that this EDUCBA information on “Help Command in Linux” was beneficial to you. You can view EDUCBA’s recommended articles for more information.