Adding a new path to user PATH variable

Do you want to execute your scripts without specifying the script full path?
Add the path of your scripts to PATH system user variable.
One of the several ways to accomplish this is by modifying the file .bashrc, located in your home directory.

Objective

We want our scripts located in “Mybins” directory in our home to be executed by using only their names, that is without the full path.
We want this config to be permanent.

.bashrc config

We need to add a line at the end of “.bashrc” to add the new path to PATH variable. In our example we need to add this:

export PATH=$PATH:$HOME/Mybins

What we are doing is to export PATH again and adding the new path.
We can add as many paths as we want, using “:” between them. For example:

export PATH=$PATH:$HOME/Mybins:/usr/share/dir

We can add this line from the command line like this:

echo "export PATH=$PATH:$HOME/Mybins" >> $HOME/.bashrc

 

Leave a Reply

Your email address will not be published. Required fields are marked *