0

I ran these 2 commands simply in the terminal:

export PATH="$PATH:/home/milkncookiez/Developer/android-studio/bin"
export PATH="$PATH:/home/milkncookiez/Developer/PhpStorm/bin"

in the 2 bin folders I have the files studio.sh and phpstorm.sh. In that same terminal session when I simply wrote the name of the files - the programs were ran.

When I opened another terminal - did not work. I added these both lines in the ~/.profile file, opened a new terminal session but it still does not work. How do I set the 2 variable changes to be permanent for all terminal sessions?

Milkncookiez
  • 455
  • 2
  • 9
  • 20

2 Answers2

2

Adding them to ~/.profile (apply to your user) or a /etc/profile.d/*.sh file (apply to the entire system) is the correct way. In order for the change to apply, you have to log out of your system and log back in, as ~/.profile and /etc/profile.d/*.sh are loaded when you login.

To 'reload' ~/.profile in a running terminal, you can use source ~/.profile

Gunnar Hjalmarsson
  • 32,938
  • 3
  • 63
  • 94
Tobias
  • 1,568
  • 2
  • 19
  • 34
  • `/etc/profile` should preferably not be edited directly. Better to add a new `/etc/profile.d/.sh` file. Anyway, given the paths added to `PATH` in this case, `~/.profile` is probably the suitable choice. – Gunnar Hjalmarsson Nov 20 '14 at 09:10
  • @Gunnar I'm not familiar with the /etc/profile.d directory so I can't confirm whether that's the case or not, but please edit my answer if using /etc/profile.d is best practice. – Tobias Nov 20 '14 at 09:23
  • Ok, done. The source is the tutorial [EnvironmentVariables](https://help.ubuntu.com/community/EnvironmentVariables#System-wide_environment_variables), and I edited that section in consultation with experienced Ubuntu developers. – Gunnar Hjalmarsson Nov 20 '14 at 10:34
1

You don't need to use export; the PATH variable is already exported at that point. Anyway, .profile is read when you log in, so what you've done is correct, but opening a new terminal does not count as logging in.

geirha
  • 45,233
  • 13
  • 70
  • 67
  • I habitually use `export` when dealing with environment variables in `~/.profile`. It's true that it's not necessary when modifying an already existing environment variable such as `PATH`, but I'm probably not going to do it otherwise in the future. That way I eliminate the risk for forgetting `export` when it's needed. ;) – Gunnar Hjalmarsson Nov 20 '14 at 10:42