07 March 2012

Difference Between External and Internal Command in Linux

1 comment

Linux commands can be broadly classified into Internal and External commands.

Internal commands are those commands which are shell built-in commands. These commands are loaded at the time of booting. Shell does not start separate process to run this commands.

Example: cd , pwd , echo etc.

External commands are those command which are stored as a separate binaries. Shell starts separate sub-process to execute them. Most external commands are stored in the form of binaries in /bin directory. To execute external command shell check $PATH variable . If command present in the   location mentioned in $PATH variable shell will execute it , otherwise it will give error.

How External Commands Located from PATH variable

Suppose output of your PATH variable is like this , if you type any external command , shell search directories specified in the PATH variable like /usr/local/sbin ,/usr/local/bin , /usr/sbin etc. If shell find executable of that command then it will execute it otherwise it will give error.

Note: If a command exist as internal and external command then internal command with same name get top priority.

How to check for External and Internal command

type utility can be used to check whether a command is internal or external.

All those commands which gives "shell builtin" message are internal commands and commands for which some path is displayed are external commands.

That's it.
Enjoy :)

If You Liked This Post Please Take a Time To Share This Post

You May Also Like...

1 comment: