Categories
microsoft windows OS

Help Command in Linux

Help Command in Linux

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 the information about the built-in commands present in the Linux shell.

Syntax:

$ 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 help command, use the following command.

$ help help

This command displays the page which contains the information about the help command itself.

Output:

Help Command in Linux-1.1

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.

Syntax:

$ help -d

2. -m Option

This option displays the output in pseudo-manpage format.

Syntax:

$ help -m

3. -s Option

This option displays only the syntax of a particular command.

Syntax:

$ help –s

Example:

$ 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.

Syntax:

$ help cd

Output:

Help Command in Linux-1.2

To display all the available information about the cd command -m option is used. This is similar to the man command.

$ help –m cd

Output:

Help Command in Linux-1.3

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.

Syntax:

$ help -d cd

The following output is produced in the system.

Output:

Help Command in Linux-1.4

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.

Syntax:

$ 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.

Output:

Help Command in Linux-1.5

For instance, if we provide password command as the parameter for the help command then you will see the error message as shown below.

Output:

Help Command in Linux-1.6

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.

Syntax:

$ compgen -b | column

Output:

Output-1.7

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.

Output:

Output-1.8

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.

Output:

Output-1.9

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.

Syntax:

$ whatis [command name]

Recommended Articles

This is a guide to Help Command in Linux. Here we discuss the Introduction and what is Help Command in Linux along with options used in help command. You may also have a look at the following articles to learn more –

Bash Shell in Linux
What is Shell in Linux?
du Command in Linux
SCP Command in Linux

The post Help Command in Linux appeared first on EDUCBA.

Read more: educba.com