Get help for shell builtins with help command

Share this post to your friends !

This entry is part 4 of 9 in the series Linux commands: Part 5 - Working with commands

WriteBash - To get help for shell builtins, use the help command. Why is that?

In Linux, we have a lot of commands. And the commands have different instructions and usage options. We can’t remember all the commands with all the options, I’m pretty sure about that. So we need help.

Use the help command to get help for shell builtins

The name of the command can tell you what it means. However, the help command is only used with builtins shells.

Note: the help command can only display help for shell builtins.

What is its syntax? Pretty simple as every other command, you look below.

$ help command

I will do some examples with the help command. First I will try it with the ls command. Through the previous article, you know that the ls command is not a builtin shell. So what will we get?

get-help-for-shell-builtins-with-help-command Get help for shell builtins with help command
Use help command to get help for shell builtins.
linuxmint ~ # help ls
bash: help: no help topics match `ls'. Try `help help' or `man -k ls' or `info ls'.

Next, I will try the help command with the cd command and you can see the result as shown below.

linuxmint ~ # help cd
cd: cd [-L|[-P [-e]] [-@]] [dir]
    Change the shell working directory.
    Change the current directory to DIR.  The default DIR is the value of the
    HOME shell variable.
    The variable CDPATH defines the search path for the directory containing
    DIR.  Alternative directory names in CDPATH are separated by a colon (:).
    A null directory name is the same as the current directory.  If DIR begins
    with a slash (/), then CDPATH is not used.
    If the directory is not found, and the shell option `cdable_vars' is set,
    the word is assumed to be  a variable name.  If that variable has a value,
    its value is used for DIR.
        -L force symbolic links to be followed: resolve symbolic links in
       DIR after processing instances of `..'
        -P use the physical directory structure without following symbolic
       links: resolve symbolic links in DIR before processing instances
       of `..'
        -e if the -P option is supplied, and the current working directory
       cannot be determined successfully, exit with a non-zero status
        -@  on systems that support it, present a file with extended attributes
            as a directory containing the file attributes
    The default is to follow symbolic links, as if `-L' were specified.
    `..' is processed by removing the immediately previous pathname component
    back to a slash or the beginning of DIR.
    Exit Status:
    Returns 0 if the directory is changed, and if $PWD is set successfully when
    -P is used; non-zero otherwise.

Note: square brackets are displayed for the option of the command.

In the example with the cd command above, the options of the command with square brackets are cd [-L|[-P [-e]] [-@]] [dir].

Display usage information with –help

In addition to using the help command, most Linux commands support the --help option.

When you type the --help syntax as shown below, the instruction manual of the command will be displayed.

$ command --help

For example, use the --help option with the mkdir command.

linuxmint ~ # mkdir --help
Usage: mkdir [OPTION]... DIRECTORY...
Create the DIRECTORY(ies), if they do not already exist.

Mandatory arguments to long options are mandatory for short options too.
  -m, --mode=MODE   set file mode (as in chmod), not a=rwx - umask
  -p, --parents     no error if existing, make parent directories as needed
  -v, --verbose     print a message for each created directory
  -Z                   set SELinux security context of each created directory
                         to the default type
      --context[=CTX]  like -Z, or if CTX is specified then set the SELinux
                         or SMACK security context to CTX
      --help     display this help and exit
      --version  output version information and exit

GNU coreutils online help: <>
Full documentation at: <>
or available locally via: info '(coreutils) mkdir invocation'

Tips: try typing --help when you’re not sure how to use that command.


Through this article, you learned how to display usage information, displaying help information for Linux commands.

Continue reading the series«« Previous part: Display an executable’s location with which commandNext part: Display a program’s manual page with man command »»
If you liked this article, then please subscribe to our YouTube Channel for more video tutorials. You can also find us on Twitter and Facebook.

Share this post to your friends !
If you appreciate what we share in this blog, you can support us by:
  1. Stay connected to: Facebook | Twitter | Google Plus | YouTube
  2. Subscribe email to recieve new posts from us: Sign up now.
  3. Start your own blog with SSD VPS - Free Let's Encrypt SSL ($2.5/month).
  4. Become a Supporter - Make a contribution via PayPal.
  5. Support us by purchasing Ribbon Lite Child theme being using on this website.

We are thankful for your support.

single post bottom banner
«« »»

Got something to say? Join the discussion

Please keep in mind that all comments are subject to our Comment Policy. Your email address will not be published.
This site uses Akismet to reduce spam. Learn how your comment data is processed.