How do I distinguish between a command, utility, or builtin for getting documentation?

I’m running Bash scripting, but sometimes I get confused which of these commands I use belong to who. Sometimes man xxx works, sometimes doesn’t, so I use --help or info, mostly one of these works to show description of the command. Can anyone tell me how I would know what command belongs to what? Bash builtin, GNU utility, etc.

Here is Solutions:

We have many solutions to this problem, But we recommend you to use the first solution because it is tested & true solution that will 100% work for you.

Solution 1

You can use type to find out:

$ type echo
echo is a shell builtin
$ type sudo
sudo is /usr/bin/sudo

For bash builtins, use help, as in help echo.

Solution 2

Some builtin commands are included for efficiency sake and exist as external commands in the first place. For example:

$ type -a echo
echo is a shell builtin
echo is /bin/echo

$ type -a printf
printf is a shell builtin
printf is /usr/bin/printf

A detailed analysis of builtins and external commands can be found in Unix & Linux.

As far as getting help for dual builtins/external commands such as echo you have two choices. One method is by using man echo:

ECHO(1)                               User Commands                               ECHO(1)

       echo - display a line of text

       echo [SHORT-OPTION]... [STRING]...
       echo LONG-OPTION

       Echo the STRING(s) to standard output.

       -n     do not output the trailing newline

       -e     enable interpretation of backslash escapes

       -E     disable interpretation of backslash escapes (default)

       --help display this help and exit

              output version information and exit

       If -e is in effect, the following sequences are recognized:

       \\     backslash

       \a     alert (BEL)

 Manual page echo(1) line 1 (press h for help or q to quit)

And you can type:

$ help echo
echo: echo [-neE] [arg ...]
    Write arguments to the standard output.

    Display the ARGs, separated by a single space character and followed by a
    newline, on the standard output.

      -n    do not append a newline
      -e    enable interpretation of the following backslash escapes
      -E    explicitly suppress interpretation of backslash escapes

    `echo' interprets the following backslash-escaped characters:
      \a    alert (bell)
      \b    backspace
      \c    suppress further output
      \e    escape character
      \E    escape character
      \f    form feed
      \n    new line
      \r    carriage return
      \t    horizontal tab
      \v    vertical tab
      \\    backslash
      \0nnn the character whose ASCII code is NNN (octal).  NNN can be
        0 to 3 octal digits
      \xHH  the eight-bit character whose value is HH (hexadecimal).  HH
        can be one or two hex digits

    Exit Status:
    Returns success unless a write error occurs.

Note: Use and implement solution 1 because this method fully tested our system.
Thank you 🙂

All methods was sourced from or, is licensed under cc by-sa 2.5, cc by-sa 3.0 and cc by-sa 4.0

Leave a Reply