Skip to content

Getting Help in Shell

There are basically two kinds of commands in the Linux world: Internal and external. Internal commands are functions built into your shell. External commands are programs installed on your system.

You can visit here for more detailed information about the differences between internal and external commands.

Internal Command Help on Linux

There are different tools you can use to get help with internal commands, ie shell builtins. Below you will find examples of these tools.

help Command

With the help command, you can get detailed information about shell commands. You can use it as help commandname:

help eval
ali@gnuadmin:~$ help eval
eval: eval [arg ...]
    Execute arguments as a shell command.

    Combine ARGs into a single string, use the result as input to the shell,
    and execute the resulting commands.

    Exit Status:
    Returns exit status of command or success if command is null.

type Command

With the type command, you can learn the type (internal or external) of the command you will run. You can also learn about your alias:

type command
ali@gnuadmin:~$ type cd
cd is a shell builtin
ali@gnuadmin:~$ type ls
ls is aliased to `ls --color=auto'
ali@gnuadmin:~$ type touch
touch is /usr/bin/touch

As can be seen from the above output; cd is an internal command, touch is an external command, and ls is an alias defined as ls --color=auto.

External Command Help on Linux

There are different tools you can use to get help with external commands. Below you will find examples of these tools.

which Command

The which command shows from which path the external command you typed will be called:

which command
root@gnuadmin:~# which ls
/usr/bin/ls
root@gnuadmin:~# which useradd
/usr/sbin/useradd
root@gnuadmin:~# which cd
root@gnuadmin:~# 

According to the above output; the ls command runs the program at the /usr/bin/ls path, while the useradd command runs the program at the /usr/sbin/useradd path. Note that no output is produced for the internal command cd.

whatis Command

With the whatis command, you can extract a single line of information from the man pages and learn about the command. Similarly, it is possible for you to learn about configuration files. The whatis resolv.conf command in the example below is an example of this situation.

whatis command
root@gnuadmin:~# whatis whatis
whatis (1)           - display one-line manual page descriptions
root@gnuadmin:~# whatis polkit
polkit (8)           - Authorization Framework
root@gnuadmin:~# whatis resolv.conf
resolv.conf (5)      - resolver configuration file

man Command

One of the biggest saviors of Linux system administrators, the man command is a tool that allows you to view the manual pages on the system.

By using man commandname you can access the manual pages written about commands.

man command
NAME
       ls - list directory contents

SYNOPSIS
       ls [OPTION]... [FILE]...

DESCRIPTION
       List information about the FILEs (the current directory by default).  Sort entries alphabetically if none of -cftuvSUX nor --sort is specified.

       Mandatory arguments to long options are mandatory for short options too.

       -a, --all
              do not ignore entries starting with .

       -A, --almost-all
              do not list implied . and ..

       --author
              with -l, print the author of each file

       -b, --escape
              print C-style escapes for nongraphic characters