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?
Asked
Active
Viewed 1.6e+01k times
53

Simone
- 633
1 Answers
61
- 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.

Gunnar Hjalmarsson
- 33,540
- 3
- 64
- 94
-
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 -
-
-
@GunnarHjalmarsson If I update the ~/.profile file for one particular user the variable doesn't get updated for other users. (Or are environment variables user-specific only? Are there system-wide/user-independent environment variables?) – akki Jul 07 '17 at 08:26
-
2@akki: Ok, now I see. Yes, you can set them system wide if you like. – Gunnar Hjalmarsson Jul 07 '17 at 17:10
-
I followed this method, now stuck in an infinite login loop. Any suggestions? – Mobeen Aug 17 '17 at 21:11
-
@Mobeen: Apparently you made a mistake. I suggest that you file a new question where you describe the problem as detailed as you can. – Gunnar Hjalmarsson Aug 17 '17 at 21:55
-
I think user need logout then login to reapply the updated .profile – MinhajulAnwar Aug 19 '18 at 16:27
-
19You don't have to logout and login again. You can simply do
source ~/.profile
to apply the changes. – Sohaib Farooqi Sep 13 '18 at 10:26 -
2@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
-
Is it correct that if you want to add the vars system wide you can use this profile file:
sudo vi /etc/profile
and add them there? – bersling May 25 '21 at 13:49
environment
answer is the most upvoted one there :) – Gallifreyan Feb 26 '17 at 10:41