Identify BASH built-in commands in Ubuntu

There are mainly two types of commands we utilize in Ubuntu or Linux. These are shell built-in commands and file system commands. We utilize commands without realizing whether its a shell built-in command or file system command. In this article, we cover how to identify a BASH built-in or a filesystem command.

The Shell commands are built-in to the shell itself. Different shells would have different built-in commands. Though, some built-in commands are common across. But, still few remain exclusive to a specific shell. So, it becomes necessary in certain situations wherein we should know if a command is a built-in or file system command.

Although, we can get the list of all built-in commands in BASH by the following command –

help

But, then we would have to scroll through the list and check for built-in commands. Certainly, that is definitely not an efficient option.

Identify BASH built-in commands in Ubuntu

To identify a built-in command, use type command-line tool. It is basically a built-in command in BASH itself. With the help of type, we can extract more information about a command type.

Use following syntax to identify a BASH built-in command –

type -t <command-name>

And, the output would be either file or builtin.

For instance, for cat command –

type -t cat

It would return with –

file

Which indicates that its a filesystem command. On the other hand, for echo command –

type -t echo

It would return with –

builtin

Clearly indicating that its a builtin command. Try with various other commands.

In conclusion, we have covered how to identify a BASH builtin command in Ubuntu here.

Additional Info –

Besides, we can also get location of the executable by using -a option. Use the following syntax –

type -a <command>

For instance, for python3 it would be –

type -a python3

For us the output was –

python3 is /usr/bin/python3
python3 is /bin/python3

Similar Posts