14

This question already has an answer here:

I am completely new to Ubuntu, and I would permanently set an environment variable. I have read here that I have to set ~/.profile, but I don't know how to apply it. In my case I would permanently set export PATH="/home/name/anaconda/bin:$PATH", how could I do?

marked as duplicate by Zanna, Gunnar Hjalmarsson, WinEunuuchs2Unix, Eric Carvalho, Community Feb 26 '17 at 22:05

This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.

  • 2
    @Zanna I think this is more useful (having used it myself): How do I set PATH variables for all users on a server?. At least because the environment answer is the most upvoted one there :) – Gallifreyan Feb 26 '17 at 10:41
  • From ubuntu docs here: help.ubuntu.com/community/… – vpedrosa Feb 26 '17 at 13:20
  • 1
    @vpedrosa: Since the folder to be added to PATH is in $HOME, it's unlikely that modifying PATH system wide applies here. – Gunnar Hjalmarsson Feb 26 '17 at 14:32
  • I had similar issue with GOPATH environment variable. I had to put export GOPATH="$HOME/path/to/workspace/", and then log back to apply the edited file – minhajul Aug 19 '18 at 16:30
24
  • Open a terminal window with Ctrl+Alt+T.
  • Open the file for editing with

    gedit ~/.profile
    
  • Add the command to the bottom of the file.

  • Save and close gedit.

  • Log out and log in again.

  • Do I have to add the entire command export PATH="/home/name/anaconda/bin:$PATH at the bottom of the file? Or I have to add it at the existing PATH? – Simone Feb 26 '17 at 14:04
  • 1
    @Simone: You should add the entire command. That way you do add the folder to the existing PATH. (Don't forget the trailing ", btw.) – Gunnar Hjalmarsson Feb 26 '17 at 14:24
  • This does it only for that particular user though. – akki Jul 5 '17 at 11:37
  • 2
    @akki: Ok, now I see. Yes, you can set them system wide if you like. – Gunnar Hjalmarsson Jul 7 '17 at 17:10
  • 1
    @bro-grammer: Doing so would only apply them in the current terminal window. Already running processes would not be aware of the changes. – Gunnar Hjalmarsson Sep 13 '18 at 13:41

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