Category Archives: Linux commands

Internal and External Linux commands

Linux commands can be classified into two categories :

  1. External
  2. Internal

Let’s look into what External Linux commands are.

External commands programs with files in /bin directory (In Linux, everything is represented in the form of files). If the files are not present in the path specified by the $PATH variable, they do not get executed. Similarly, if the files are available but are not present int the path specified by $PATH, the commands cannot be executed. Another point worth noting is that every time an external command gets executed, a new process gets spawned.

Internal commands are those which are directly executed by the shell. These are built-ins in the shell. They do not depend on paths since they are not coded in files. Unlike external commands no process is created when an internal command is executed.

How to distinguish between internal and external commands ?

There is a Linux command type, which (quoting the Wikipedia) specifies how its arguments would be interpreted if they were used as a command name. This command could be used to identify between the two types of commands. Execute the command : type <command>

If the output states that the command is shell built-in, it is an internal command. Instead, if the output states that the command is present in /bin, then it is an external command.

For example, cd and pwd are examples of internal commands.


savita@Amrita:~$ type cd
cd is a shell builtin
savita@Amrita:~$ type pwd
pwd is a shell builtin
savita@Amrita:~$

cp and mv are examples of external commands.


savita@Amrita:~$ type cp
cp is /bin/cp
savita@Amrita:~$ type mv
mv is /bin/mv
savita@Amrita:~$

However, there might be certain commands which have files in /bin directory and at the same time, are also built-ins in the shell. In such cases, the first preference would always be given to the internal command, meaning that, even if the corresponding file did not exist, it would be executed by the shell as a built-in. One example is the Linux command echo.

Differences between the two types of commands :

Summarizing the above two paragraphs, some of the differences between internal and external commands (from what I understood about them) are :

External Linux Commands

Internal Linux Commands

These are executed by the kernel. These are executed by the shell.
A separate process is spawned every time a new external command is executed. No new process is created.
These are separate files in /bin directory. The execution of these commands happens through the execution of their corresponding files in /bin directory. These are built-ins in the shell. The execution of these commands happens through the execution of their corresponding files in /bin directory.
A few examples are cp, mv, etc. Some examples are cd, pwd, etc.

References : 1   2

Linux command : uname

Recently, I came across a Linux command that I found really helpful and I am sure you’ll find it helpful as well, especially when you’d like to install something on your system and are in desperate need of information about the Operation System or the Linux distribution that you are using. The command that I was referring to is ‘uname’. This command prints almost all the information that you want about the system. Some of the very useful arguments of this command that I found are as follows :

1. The -a option gives the user, complete information about the system in the order : kernel name, node name, kernel release, kernel version, hardware name, processor type, hardware platform, operating system.

uname -a

2. The -m option displays whether you are running a 32 bit or 64 bit version of Linux distribution. ( If it is a 32 bit Linux distribution – i686 will get displayed as a result of running the following command, whereas if it is a 64 bit distribution, then x86_64. )

uname -m