We can classify all of the Linux/Unix commands into two types- Internal And External. Internal commands are the shell built-in commands while external commands are  files present in the $PATH. (Remember we treat everything in the Linux as a file). Commands like pwd, cd ,echo comes under the category of the  internal commands while ls,cp etc comes in the other category. To check whether the command is internal  or external we will use the typeutility (type itself is internal one). Just type the name of the command after the utility and it will return you something like this -

Using Type Utility

If you got a message like “cd is a shell builtin” after the execution of the command  it is an internal command. If you got something else it comes under the category of external commands (like cp in this case).

How Execution  Takes Place : For the external commands, execution is possible  only if the command file is present in the locations mentioned in the $PATH. Otherwise it will give you an error.If the command file is available  , but the path to that file is not included in the PATH variable, it will show you an error. Internal commands don’t need files for their execution. Set of internal commands is stored in shell by default. Sometimes a command with the same name exist in both the categories. Example – echo (external one lies in the /bin/echo) . In this case shell will give preference to the  internal echo first, then comes the turn of the external ones.  So if you use the echo utility internal will get executed. External echo rarely gets executed (You can execute it in the shell  by creating a subshell though).

Pages : Follow ankurtwi on Twitter