I'm using a script to export a path like this:

echo "export MONO_PATH=~/turbo/" >> ~/.profile;

So from now on, the path will be available whenever the user logs in. However, I want to the path to be effective without requiring the user to log out and in again. Currently, this is my solution:

source ~/.profile;

This works, but only for the currently running terminal session. If the user opens a new one, the path won't be available (unless he logs out of course).

Additionally to adding the path to .profile, how can I make the changes effective system-wide and immediately?

  • That depends on your window manager. Unfortunately they don't all offer this functionality. What window manager are you using? – Gilles 'SO- stop being evil' Mar 6 '16 at 16:14

Put it in a shell startup file that will get included on shell startup regardless of whether that's a login or not.

For bash, that would be .bashrc.

(You should probably use $HOME instead of ~).

  • So i wouldn't need to include the export in .profile when it's in .bashrc, correct? – mınxomaτ Mar 6 '16 at 11:55
  • Since it's just a set operation (=running it twice is OK), you might as well have it in both files. You could also source .profile from .bashrc, depending on whether it's safe to eval your particular .profile twice or not. – PSkocik Mar 6 '16 at 12:02
  • This only works for programs started from an interactive shell, not for programs started directly by the window manager or other GUI launcher. – Gilles 'SO- stop being evil' Mar 6 '16 at 16:15

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.