tutason.blogg.se

What is the purpose of the path variable
What is the purpose of the path variable








) indicates the working directory) or /home/bob/script. Set up your PATH variable so that it causes the shell to search the following directories in order.

what is the purpose of the path variable

In the example above we could execute the script by entering. What is the purpose of the PATH variablea. Note that we can execute the script located in the /home/bob directory by providing the absoulte or relative path to the script. This is because the system checks for commands only in directories listed in the PATH variable. But what if we move the script to other directory that is not listed in the PATH variable?įrom the output above you can see that, although our working directory is /home/bob, the directory in which the script script.sh is located, we can’t execute it. This is because the script is located in the /bin directory, the directory listed in the PATH variable. In the example above you can see that, although our working directory is /home/bob, we were able to execute a script called script.sh. If the script is placed in the folder listed in the PATH variable, we can run the script regardless of the directory we are currently in:

what is the purpose of the path variable

Let’s say that we have a script named script.sh and we want to execute it.

what is the purpose of the path variable

For example, if PATH is set to /bin:/usr/sbin and you type echo, Linux looks for an executable program called echo in /bin and then in /usr/sbin. This variable holds the colon-separated list of directories used to find commands that you enter. One of the most important environment variables on Linux operating systems is the PATH variable.










What is the purpose of the path variable