To add directories into your Path in Ubuntu Linux, first, run the following command to edit the .bashrc file.
sudo nano ~/.bashrc
At the very end you can add different directories to the $PATH variable by adding a line like so: “export PATH=[PATH_2]:[PATH_1]:$PATH”. Each of the paths is separated by a semicolon and at the end include the $PATH variable. In the following example I am going to add 2 paths variables, one for composer programs I install and one for npm programs I install:
- ~/.npm-global/bin
- $HOME/.config/composer/vendor/bin
To add the 2 paths above I added the following line at the end of the .bashrc file:
export PATH=~/.npm-global/bin:$HOME/.config/composer/vendor/bin:$PATH
After adding the line save the file using nano by pressing Ctrl + O, then Ctrl + X to exit.