Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Setting path variables in Ubuntu

Tags:

ubuntu

I am using Ubuntu 16.04 and I want to change the PATH variable. I know that I can do this by adding export PATH=/home/patrick/.npm/bin:$PATH to for example ~/.profile. Now if I do this and then use source ~/.profile everything is fine and echo $PATH gives me the PATH variable with my change. But if I restart Ubuntu ~/.profile apparently doesn't get sourced and I am left with just the basic PATH set in /etc/environment.

I also tried using one of the other configuration files, namely /etc/profile, /etc/environment and ~/pam_environment with the same results. What is even more strange is that my ~/.profile file now has this content:

export HP_HOME=/home/patrick/git/www/p8.de/predic8.de

export PATH=/home/patrick/.npm/bin:$PATH
export PATH=/home/patrick/.npm-global/bin:$PATH

export PATH=/home/patrick/.config/composer/vendor/bin:$PATH
export PATH=/usr/local/bin/composer:$PATH

export PATH=/home/patrick/.local/share/umake/bin:$PATH

and HP_HOME gets set succesfully after each reboot. What am I missing here?

like image 599
Patrick Seume Avatar asked Dec 05 '25 18:12

Patrick Seume


2 Answers

Put it at the end of your ~/.bashrc.

like image 191
DevonDahon Avatar answered Dec 08 '25 20:12

DevonDahon


you can add your path on /etc/environment

for the example inside this file can seen like this PATH="/usr/local/sbin"

and you can add new path like this PATH="/usr/local/sbin:/myhomefolder/mygame"

don't forget to add : for the separator

and restart your computer

and this is permanent

like image 43
Arian Saputra Avatar answered Dec 08 '25 20:12

Arian Saputra