On Linux, several commands are loaded into the memory whenever a user launches the shell. These commands are a part of the shell, also known as shell builtin commands.

In this article, we will discuss shell builtins in detail, along with a guide on how you can check if a Linux command is shell builtin.

What Are Shell Builtins?

Bash builtins manpage

Shell builtins are, as the name suggests, commands that are built into the shell. This is because it's faster to run commonly used commands from RAM rather than looking them up on the hard drive. Shell developers figure that this is a good tradeoff as loading data from the memory is faster in comparison to disks.

A common example in many modern shells is the cd command to change directories. Because you'll use this command many times in a single session, it makes sense to load it in the memory for faster execution.

Related: Faster RAM vs. More RAM: Which Is Better For Performance?

How to Identify a Shell Builtin Command?

To determine if a command is a regular command or a shell builtin, use the type command. The basic syntax to check whether a Linux command is a shell builtin is:

        type -t commandname
    

...where commandname is the name of the command that you want to check.

For example, to check if the cd command is a shell builtin:

        type -t cd
    

Output:

        builtin
    

If the output displays anything other than builtin, such as file or alias, then the command is not a shell builtin command.

In Bash, you can also use command -v to identify if a command is a shell builtin. The output will display the command name if it is a builtin. For example, to check if the cd command is a shell builtin:

        command -v cd
    

Alternatively, you can also use the which command. This command will tell you the absolute pathname of a command or if it is a shell builtin or an alias. The which command might be a shell builtin itself depending on the shell you use.

zsh which command output

The manual page of a shell will also list the shell's builtin commands. Zsh devotes an entire page to builtins. This isn't surprising, given how feature-packed zsh is, which is what endears it to so many power users.

Because different shells have different builtins, a common utility that might be a shell builtin might also exist as a standalone executable on a system. If you want to use a regular command, just use its absolute pathname.

Now You Know the Difference Between Regular Commands and Shell Builtins

With even low-end modern computers much more powerful than the minicomputers of the original Unix era, shell developers can use more builtins to speed up the system. You can take advantage of shell builtins while still using regular commands if you need certain options.

Different shells have different features and therefore different builtins. Picking the right shell is a matter of which features are important to you.