PATH is a system-level variable that holds a list of directories. When you enter a command in the terminal, it’s shorthand for a program with the same name. The system looks in each of the PATH directories for the program corresponding to the command. When it finds a matching program, it runs it. If it doesn’t find a match, it raises an error.
for instance if you type $echo $PATH, first terminal will look for the echo program in system, if its present terminal will execute it with argument $PATH. then its echo programs responsibility to print something on the screen.
if you want to know where the echo program is located in your system you can find it using which program. like this $ which echo. again which is also a program located somewhere in system even you can do this $ which which
If we enter a command name that doesn’t exist in any PATH directory, we get an error: command not found.
No comments:
Post a Comment