Some commands in Unix are internal, built into the shell. For example, the cd command is built-in. That is, the shell interprets the command and changes the current directory. On the other hand, cat command is an external program stored in the file /bin/cat. The shell doesn’t start a separate process to run internal commands. External commands require the shell to run a new subprocess; this takes some time, especially if the system is busy.
Internal commands are functions that are built into the command interpreter, External commands are those not included in the interpreter, and are instead invoked by calling an external binary. Whether or not a particular command is internal or external varies by system. For example, echo is an internal command in MS-DOS (it is built into COMMAND.COM),
When you type the name of a command, the shell first checks to see if it is a built-in command and, if so, executes it. If the command name is an absolute pathname beginning with /, like /bin/ls, there is no problem: the command is likewise executed. UNIX system programs are kept in directories called /bin and /usr/bin, with additional programs usually used only by system administrators in /etc and /usr/etc. Many versions of UNIX also have programs stored in /usr/ucb (named after the University of California at Berkeley, where many UNIX programs were written). There may be other directories containing programs. For example, the programs that make up the X Window System are stored in /usr/bin/X11. Users or sites often also have their own directories where custom commands and scripts are kept, such as /usr/local/bin. The search path is stored in an environment variable called PATH. A typical PATH setting might look something like this: PATH=/bin:/usr/bin:/usr/bin/X11:/usr/ucb:/home/tim/bin: The path is searched in order, so if there are two commands with the same name, the one that is found first in the path will be executed. You can add new directories to your search path on the fly, but the path is usually set in shell setup files.
Pranjal pandey Sanij pokharel Sudarshan dhakal