Get help for shell builtins with help command

by Daniel Pham
Published: Updated:
This entry is part 4 of 9 in the series Linux commands: Part 5 - Working with commands

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?

use help command to get help for shell builtins
Use help command to get help for shell builtins.
$ 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.

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

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

(This is an article from my old blog that has been inactive for a long time, I don’t want to throw it away so I will keep it and hope it helps someone).

0 0 votes
Article Rating
Series Navigation«« Previous part: Display an executable’s location with which commandNext part: Display a program’s manual page with man command »»

You may also like

Notify of
Inline Feedbacks
View all comments

DevOps Lite is a personal blog specializing in technology with main topics about DevOps, DevSecOps, SRE and System Administrator. Articles are shared for free and contributed to the community.



Subscribe my Newsletter for new blog posts. Stay updated from your inbox!

© 2021-2024 – All rights reserved.

Please write sources “” when using articles from this website.

This website uses cookies to improve your experience. We'll assume you're ok with this, but you can opt-out if you wish. Accept Read More

Would love your thoughts, please comment.x

Adblock Detected

Please support us by disabling your AdBlocker extension from your browsers for our website.