Linux: Change the PATH [ Add New Directory ]

Linux: Change the PATH [ Add New Directory ]

To add a new directory to the PATH environment variable in Linux, you can use the export command. This command allows you to modify the PATH variable and add a new directory to it.

Here is an example of how to use the export command to add a new directory to the PATH variable:

‮ot refer‬:lautturi.com
# Add the /usr/local/bin directory to the end of the PATH variable
export PATH=$PATH:/usr/local/bin

In this example, the export command is used to modify the PATH variable and add the /usr/local/bin directory to it. The $PATH variable is expanded to its current value, and then the :/usr/local/bin string is appended to it. This will add the /usr/local/bin directory to the end of the PATH variable.

Note that the changes made to the PATH variable using the export command only apply to the current shell session. If you want to permanently add a directory to the PATH variable, you will need to modify the appropriate configuration file, such as ~/.bashrc or /etc/environment, and add the export command to it. Consult the documentation for your Linux distribution for more information about modifying the PATH variable.

Created Time:2017-10-16 14:38:53  Author:lautturi