How do I modify my PATH so that the changes are available in every Terminal session
I want to add a directory to search my search path. I know I have to modify the PATH
environment variable. However, I want the change to be permanent, so that it is always in effect, for every Terminal (bash) window I open.
There is an overload of confusing and possibly conflicting information in https://help.ubuntu.com/community/EnvironmentVariables
I am using Ubuntu 10.04. Suppose I want to add /usr/local/foo
to my PATH
. Which file (.bashrc
, .profile
, .bash_login
, etc...) should I modify and what should the new line(s) look like?
bash environment-variables
add a comment |
I want to add a directory to search my search path. I know I have to modify the PATH
environment variable. However, I want the change to be permanent, so that it is always in effect, for every Terminal (bash) window I open.
There is an overload of confusing and possibly conflicting information in https://help.ubuntu.com/community/EnvironmentVariables
I am using Ubuntu 10.04. Suppose I want to add /usr/local/foo
to my PATH
. Which file (.bashrc
, .profile
, .bash_login
, etc...) should I modify and what should the new line(s) look like?
bash environment-variables
add a comment |
I want to add a directory to search my search path. I know I have to modify the PATH
environment variable. However, I want the change to be permanent, so that it is always in effect, for every Terminal (bash) window I open.
There is an overload of confusing and possibly conflicting information in https://help.ubuntu.com/community/EnvironmentVariables
I am using Ubuntu 10.04. Suppose I want to add /usr/local/foo
to my PATH
. Which file (.bashrc
, .profile
, .bash_login
, etc...) should I modify and what should the new line(s) look like?
bash environment-variables
I want to add a directory to search my search path. I know I have to modify the PATH
environment variable. However, I want the change to be permanent, so that it is always in effect, for every Terminal (bash) window I open.
There is an overload of confusing and possibly conflicting information in https://help.ubuntu.com/community/EnvironmentVariables
I am using Ubuntu 10.04. Suppose I want to add /usr/local/foo
to my PATH
. Which file (.bashrc
, .profile
, .bash_login
, etc...) should I modify and what should the new line(s) look like?
bash environment-variables
bash environment-variables
edited Jun 3 '17 at 15:45
Zanna
50.9k13136241
50.9k13136241
asked Sep 6 '10 at 16:56
Joshua FlanaganJoshua Flanagan
4881510
4881510
add a comment |
add a comment |
6 Answers
6
active
oldest
votes
The following command adds a path to your current path:
export PATH=$PATH:/my/custom/path
If you want your setup to execute this command every time, there are a number of places where you can put it. When you login, the following scripts will be executed in this order:
/etc/profile (which starts by loading everything in /etc/profile.d)
~/.profile (which starts by loading ~/.bashrc if you are running bash)
Notes
~/.profile
is only loaded if~/.bash_profile
and~/.bash_login
DO NOT EXIST. Otherwise, at least bash, will load them instead. It is advisable to use.profile
and not the bash specific scripts. So, if in these attempts you created.bash_login
, please delete it now.~/.bashrc
is only loaded if you are running an interactive session. (something with a prompt where you can actually type something).~/.bashrc
is loaded again and again, every time you open up a new terminal. So a new tab in gnome-terminal, a new virtual terminal, etc. So even if you don't login again,.bashrc
is loaded (and thereby resets its environment) every time you open a new shell.Things like byobu should really go into
.profile
, (otherwise it won't work ;-)Things like paths should go into
.profile
if you want them to work outside of the interactive sessions. (say when you press Alt+F2 in GNOME)
I'll mark this as the answer if you update it to include the requested export line that should be added to .profile.
– Joshua Flanagan
Sep 8 '10 at 0:13
This used to be valid only for console logins (e.g. ssh, or the virtual terminals accessible for Ctrl+Alt+Fx). I didn't know that /etc/gdm/Xsession sources ~/.profile these days. Neat!
– Marius Gedminas
Sep 9 '10 at 14:31
Yeah, i didn't mention /etc/gdm/Xsession specifically or ~/.Xprofile because there are better ways to make graphical programs launch at start up, which does garantuee that the rest of the environment is already loaded.
– Ralf
Sep 10 '10 at 15:14
1
to make this answer more comprehensive please add MattH's comment about sourcing ~/.profile to activate changes without a logoff/on cycle.
– matt wilkie
Nov 17 '10 at 21:36
1
@schwiz:~/.profile
is not executed on each terminal, it is executed before, when your desktop session starts. The one executed on every terminal is~/.bashrc
– MestreLion
Apr 11 '13 at 8:28
|
show 2 more comments
I got it to work by modifying ~/.profile
It looks like adding ~/bin to my path was a bad example, as there is already code in ~/.profile to do that automatically, if the directory exists.
To add the usr/local/foo directory to my path for every session going forward, I add/edit the following line at the end of my .profile:
export PATH=$PATH:/usr/local/foo
However, to make this take effect, I needed to log out and log back in (simply closing the Terminal window and opening a new one did NOT work).
4
Make thatexport PATH="$PATH:/usr/foo"
, in case you ever have spaces or other special characters in$PATH
.
– Gilles
Sep 6 '10 at 19:52
3
You can reload the current environment without logging out by typing ". ~/.profile"
– Matt H
Sep 7 '10 at 2:30
1
@MattH: no you can't. if you source~/.profile
in a given terminal, it will be effective for that terminal only
– MestreLion
Apr 11 '13 at 8:32
@MestreLion - you are right. I was mentioning it for convenience for the current terminal. Forgot to add that.
– Matt H
Apr 18 '13 at 1:18
What if I already have something in PATH? Could I append to it like PATHS work in Windows? For example I havePATH="$HOME/bin:$HOME/.local/bin:$PATH"
already.
– Gabriel Fair
Oct 27 '17 at 22:29
add a comment |
To reload .profile and take changes effects without logout/login, run:
source ~/.profile
add a comment |
You can add the path to /etc/environment
, but be aware that no shell expansions will work; the variable will be set to literally the characters you enter.
Out of the two methods(adding export command in .profile and adding full path name to PATH in etc/environment), which should be preferred?
– Rohan Bhatia
Jan 3 '18 at 13:14
add a comment |
Youcan modify the .bashrc
file in your $HOME
directory.
At the very end of this file, add the line:
export PATH="$HOME/directory_to_include_in_path/:$PATH"
You can also modify the .profile
file, also in your $HOME
directory, including the following line:
PATH="$HOME/directory_to_include_in_path/:$PATH"
This worked for me.
2
I don't see what this adds to the other answers which explain more thoroughly.
– Zanna
Jun 3 '17 at 15:47
add a comment |
Going through the basics, I will suggest the following steps:
1. It's recommended to set environment variables in /etc/environment
2. Open the file as superuser in an editor as it's a read only file e.g. gedit:
gksu gedit /etc/environment
3. System will need password to open it in editable mode. Enter your superuser password and get file opened in a new gedit window.
4. Add new line at the end of file with
export PATH=$PATH:/usr/local/foo
5. Save and close the window. It will get command back to terminal.
6. Refresh the environment by running the following command:
. /etc/environment
7. You may check by executing the following command:
echo $PATH
This is incorrect and will not work. Parameter expansion is not performed in/etc/environment
– Zanna
Jun 3 '17 at 15:16
add a comment |
Your Answer
StackExchange.ready(function() {
var channelOptions = {
tags: "".split(" "),
id: "89"
};
initTagRenderer("".split(" "), "".split(" "), channelOptions);
StackExchange.using("externalEditor", function() {
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled) {
StackExchange.using("snippets", function() {
createEditor();
});
}
else {
createEditor();
}
});
function createEditor() {
StackExchange.prepareEditor({
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader: {
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
},
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
});
}
});
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2faskubuntu.com%2fquestions%2f3744%2fhow-do-i-modify-my-path-so-that-the-changes-are-available-in-every-terminal-sess%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
6 Answers
6
active
oldest
votes
6 Answers
6
active
oldest
votes
active
oldest
votes
active
oldest
votes
The following command adds a path to your current path:
export PATH=$PATH:/my/custom/path
If you want your setup to execute this command every time, there are a number of places where you can put it. When you login, the following scripts will be executed in this order:
/etc/profile (which starts by loading everything in /etc/profile.d)
~/.profile (which starts by loading ~/.bashrc if you are running bash)
Notes
~/.profile
is only loaded if~/.bash_profile
and~/.bash_login
DO NOT EXIST. Otherwise, at least bash, will load them instead. It is advisable to use.profile
and not the bash specific scripts. So, if in these attempts you created.bash_login
, please delete it now.~/.bashrc
is only loaded if you are running an interactive session. (something with a prompt where you can actually type something).~/.bashrc
is loaded again and again, every time you open up a new terminal. So a new tab in gnome-terminal, a new virtual terminal, etc. So even if you don't login again,.bashrc
is loaded (and thereby resets its environment) every time you open a new shell.Things like byobu should really go into
.profile
, (otherwise it won't work ;-)Things like paths should go into
.profile
if you want them to work outside of the interactive sessions. (say when you press Alt+F2 in GNOME)
I'll mark this as the answer if you update it to include the requested export line that should be added to .profile.
– Joshua Flanagan
Sep 8 '10 at 0:13
This used to be valid only for console logins (e.g. ssh, or the virtual terminals accessible for Ctrl+Alt+Fx). I didn't know that /etc/gdm/Xsession sources ~/.profile these days. Neat!
– Marius Gedminas
Sep 9 '10 at 14:31
Yeah, i didn't mention /etc/gdm/Xsession specifically or ~/.Xprofile because there are better ways to make graphical programs launch at start up, which does garantuee that the rest of the environment is already loaded.
– Ralf
Sep 10 '10 at 15:14
1
to make this answer more comprehensive please add MattH's comment about sourcing ~/.profile to activate changes without a logoff/on cycle.
– matt wilkie
Nov 17 '10 at 21:36
1
@schwiz:~/.profile
is not executed on each terminal, it is executed before, when your desktop session starts. The one executed on every terminal is~/.bashrc
– MestreLion
Apr 11 '13 at 8:28
|
show 2 more comments
The following command adds a path to your current path:
export PATH=$PATH:/my/custom/path
If you want your setup to execute this command every time, there are a number of places where you can put it. When you login, the following scripts will be executed in this order:
/etc/profile (which starts by loading everything in /etc/profile.d)
~/.profile (which starts by loading ~/.bashrc if you are running bash)
Notes
~/.profile
is only loaded if~/.bash_profile
and~/.bash_login
DO NOT EXIST. Otherwise, at least bash, will load them instead. It is advisable to use.profile
and not the bash specific scripts. So, if in these attempts you created.bash_login
, please delete it now.~/.bashrc
is only loaded if you are running an interactive session. (something with a prompt where you can actually type something).~/.bashrc
is loaded again and again, every time you open up a new terminal. So a new tab in gnome-terminal, a new virtual terminal, etc. So even if you don't login again,.bashrc
is loaded (and thereby resets its environment) every time you open a new shell.Things like byobu should really go into
.profile
, (otherwise it won't work ;-)Things like paths should go into
.profile
if you want them to work outside of the interactive sessions. (say when you press Alt+F2 in GNOME)
I'll mark this as the answer if you update it to include the requested export line that should be added to .profile.
– Joshua Flanagan
Sep 8 '10 at 0:13
This used to be valid only for console logins (e.g. ssh, or the virtual terminals accessible for Ctrl+Alt+Fx). I didn't know that /etc/gdm/Xsession sources ~/.profile these days. Neat!
– Marius Gedminas
Sep 9 '10 at 14:31
Yeah, i didn't mention /etc/gdm/Xsession specifically or ~/.Xprofile because there are better ways to make graphical programs launch at start up, which does garantuee that the rest of the environment is already loaded.
– Ralf
Sep 10 '10 at 15:14
1
to make this answer more comprehensive please add MattH's comment about sourcing ~/.profile to activate changes without a logoff/on cycle.
– matt wilkie
Nov 17 '10 at 21:36
1
@schwiz:~/.profile
is not executed on each terminal, it is executed before, when your desktop session starts. The one executed on every terminal is~/.bashrc
– MestreLion
Apr 11 '13 at 8:28
|
show 2 more comments
The following command adds a path to your current path:
export PATH=$PATH:/my/custom/path
If you want your setup to execute this command every time, there are a number of places where you can put it. When you login, the following scripts will be executed in this order:
/etc/profile (which starts by loading everything in /etc/profile.d)
~/.profile (which starts by loading ~/.bashrc if you are running bash)
Notes
~/.profile
is only loaded if~/.bash_profile
and~/.bash_login
DO NOT EXIST. Otherwise, at least bash, will load them instead. It is advisable to use.profile
and not the bash specific scripts. So, if in these attempts you created.bash_login
, please delete it now.~/.bashrc
is only loaded if you are running an interactive session. (something with a prompt where you can actually type something).~/.bashrc
is loaded again and again, every time you open up a new terminal. So a new tab in gnome-terminal, a new virtual terminal, etc. So even if you don't login again,.bashrc
is loaded (and thereby resets its environment) every time you open a new shell.Things like byobu should really go into
.profile
, (otherwise it won't work ;-)Things like paths should go into
.profile
if you want them to work outside of the interactive sessions. (say when you press Alt+F2 in GNOME)
The following command adds a path to your current path:
export PATH=$PATH:/my/custom/path
If you want your setup to execute this command every time, there are a number of places where you can put it. When you login, the following scripts will be executed in this order:
/etc/profile (which starts by loading everything in /etc/profile.d)
~/.profile (which starts by loading ~/.bashrc if you are running bash)
Notes
~/.profile
is only loaded if~/.bash_profile
and~/.bash_login
DO NOT EXIST. Otherwise, at least bash, will load them instead. It is advisable to use.profile
and not the bash specific scripts. So, if in these attempts you created.bash_login
, please delete it now.~/.bashrc
is only loaded if you are running an interactive session. (something with a prompt where you can actually type something).~/.bashrc
is loaded again and again, every time you open up a new terminal. So a new tab in gnome-terminal, a new virtual terminal, etc. So even if you don't login again,.bashrc
is loaded (and thereby resets its environment) every time you open a new shell.Things like byobu should really go into
.profile
, (otherwise it won't work ;-)Things like paths should go into
.profile
if you want them to work outside of the interactive sessions. (say when you press Alt+F2 in GNOME)
edited Jun 3 '17 at 15:40
Zanna
50.9k13136241
50.9k13136241
answered Sep 6 '10 at 18:25
RalfRalf
1,640118
1,640118
I'll mark this as the answer if you update it to include the requested export line that should be added to .profile.
– Joshua Flanagan
Sep 8 '10 at 0:13
This used to be valid only for console logins (e.g. ssh, or the virtual terminals accessible for Ctrl+Alt+Fx). I didn't know that /etc/gdm/Xsession sources ~/.profile these days. Neat!
– Marius Gedminas
Sep 9 '10 at 14:31
Yeah, i didn't mention /etc/gdm/Xsession specifically or ~/.Xprofile because there are better ways to make graphical programs launch at start up, which does garantuee that the rest of the environment is already loaded.
– Ralf
Sep 10 '10 at 15:14
1
to make this answer more comprehensive please add MattH's comment about sourcing ~/.profile to activate changes without a logoff/on cycle.
– matt wilkie
Nov 17 '10 at 21:36
1
@schwiz:~/.profile
is not executed on each terminal, it is executed before, when your desktop session starts. The one executed on every terminal is~/.bashrc
– MestreLion
Apr 11 '13 at 8:28
|
show 2 more comments
I'll mark this as the answer if you update it to include the requested export line that should be added to .profile.
– Joshua Flanagan
Sep 8 '10 at 0:13
This used to be valid only for console logins (e.g. ssh, or the virtual terminals accessible for Ctrl+Alt+Fx). I didn't know that /etc/gdm/Xsession sources ~/.profile these days. Neat!
– Marius Gedminas
Sep 9 '10 at 14:31
Yeah, i didn't mention /etc/gdm/Xsession specifically or ~/.Xprofile because there are better ways to make graphical programs launch at start up, which does garantuee that the rest of the environment is already loaded.
– Ralf
Sep 10 '10 at 15:14
1
to make this answer more comprehensive please add MattH's comment about sourcing ~/.profile to activate changes without a logoff/on cycle.
– matt wilkie
Nov 17 '10 at 21:36
1
@schwiz:~/.profile
is not executed on each terminal, it is executed before, when your desktop session starts. The one executed on every terminal is~/.bashrc
– MestreLion
Apr 11 '13 at 8:28
I'll mark this as the answer if you update it to include the requested export line that should be added to .profile.
– Joshua Flanagan
Sep 8 '10 at 0:13
I'll mark this as the answer if you update it to include the requested export line that should be added to .profile.
– Joshua Flanagan
Sep 8 '10 at 0:13
This used to be valid only for console logins (e.g. ssh, or the virtual terminals accessible for Ctrl+Alt+Fx). I didn't know that /etc/gdm/Xsession sources ~/.profile these days. Neat!
– Marius Gedminas
Sep 9 '10 at 14:31
This used to be valid only for console logins (e.g. ssh, or the virtual terminals accessible for Ctrl+Alt+Fx). I didn't know that /etc/gdm/Xsession sources ~/.profile these days. Neat!
– Marius Gedminas
Sep 9 '10 at 14:31
Yeah, i didn't mention /etc/gdm/Xsession specifically or ~/.Xprofile because there are better ways to make graphical programs launch at start up, which does garantuee that the rest of the environment is already loaded.
– Ralf
Sep 10 '10 at 15:14
Yeah, i didn't mention /etc/gdm/Xsession specifically or ~/.Xprofile because there are better ways to make graphical programs launch at start up, which does garantuee that the rest of the environment is already loaded.
– Ralf
Sep 10 '10 at 15:14
1
1
to make this answer more comprehensive please add MattH's comment about sourcing ~/.profile to activate changes without a logoff/on cycle.
– matt wilkie
Nov 17 '10 at 21:36
to make this answer more comprehensive please add MattH's comment about sourcing ~/.profile to activate changes without a logoff/on cycle.
– matt wilkie
Nov 17 '10 at 21:36
1
1
@schwiz:
~/.profile
is not executed on each terminal, it is executed before, when your desktop session starts. The one executed on every terminal is ~/.bashrc
– MestreLion
Apr 11 '13 at 8:28
@schwiz:
~/.profile
is not executed on each terminal, it is executed before, when your desktop session starts. The one executed on every terminal is ~/.bashrc
– MestreLion
Apr 11 '13 at 8:28
|
show 2 more comments
I got it to work by modifying ~/.profile
It looks like adding ~/bin to my path was a bad example, as there is already code in ~/.profile to do that automatically, if the directory exists.
To add the usr/local/foo directory to my path for every session going forward, I add/edit the following line at the end of my .profile:
export PATH=$PATH:/usr/local/foo
However, to make this take effect, I needed to log out and log back in (simply closing the Terminal window and opening a new one did NOT work).
4
Make thatexport PATH="$PATH:/usr/foo"
, in case you ever have spaces or other special characters in$PATH
.
– Gilles
Sep 6 '10 at 19:52
3
You can reload the current environment without logging out by typing ". ~/.profile"
– Matt H
Sep 7 '10 at 2:30
1
@MattH: no you can't. if you source~/.profile
in a given terminal, it will be effective for that terminal only
– MestreLion
Apr 11 '13 at 8:32
@MestreLion - you are right. I was mentioning it for convenience for the current terminal. Forgot to add that.
– Matt H
Apr 18 '13 at 1:18
What if I already have something in PATH? Could I append to it like PATHS work in Windows? For example I havePATH="$HOME/bin:$HOME/.local/bin:$PATH"
already.
– Gabriel Fair
Oct 27 '17 at 22:29
add a comment |
I got it to work by modifying ~/.profile
It looks like adding ~/bin to my path was a bad example, as there is already code in ~/.profile to do that automatically, if the directory exists.
To add the usr/local/foo directory to my path for every session going forward, I add/edit the following line at the end of my .profile:
export PATH=$PATH:/usr/local/foo
However, to make this take effect, I needed to log out and log back in (simply closing the Terminal window and opening a new one did NOT work).
4
Make thatexport PATH="$PATH:/usr/foo"
, in case you ever have spaces or other special characters in$PATH
.
– Gilles
Sep 6 '10 at 19:52
3
You can reload the current environment without logging out by typing ". ~/.profile"
– Matt H
Sep 7 '10 at 2:30
1
@MattH: no you can't. if you source~/.profile
in a given terminal, it will be effective for that terminal only
– MestreLion
Apr 11 '13 at 8:32
@MestreLion - you are right. I was mentioning it for convenience for the current terminal. Forgot to add that.
– Matt H
Apr 18 '13 at 1:18
What if I already have something in PATH? Could I append to it like PATHS work in Windows? For example I havePATH="$HOME/bin:$HOME/.local/bin:$PATH"
already.
– Gabriel Fair
Oct 27 '17 at 22:29
add a comment |
I got it to work by modifying ~/.profile
It looks like adding ~/bin to my path was a bad example, as there is already code in ~/.profile to do that automatically, if the directory exists.
To add the usr/local/foo directory to my path for every session going forward, I add/edit the following line at the end of my .profile:
export PATH=$PATH:/usr/local/foo
However, to make this take effect, I needed to log out and log back in (simply closing the Terminal window and opening a new one did NOT work).
I got it to work by modifying ~/.profile
It looks like adding ~/bin to my path was a bad example, as there is already code in ~/.profile to do that automatically, if the directory exists.
To add the usr/local/foo directory to my path for every session going forward, I add/edit the following line at the end of my .profile:
export PATH=$PATH:/usr/local/foo
However, to make this take effect, I needed to log out and log back in (simply closing the Terminal window and opening a new one did NOT work).
edited Sep 8 '10 at 0:12
answered Sep 6 '10 at 17:07
Joshua FlanaganJoshua Flanagan
4881510
4881510
4
Make thatexport PATH="$PATH:/usr/foo"
, in case you ever have spaces or other special characters in$PATH
.
– Gilles
Sep 6 '10 at 19:52
3
You can reload the current environment without logging out by typing ". ~/.profile"
– Matt H
Sep 7 '10 at 2:30
1
@MattH: no you can't. if you source~/.profile
in a given terminal, it will be effective for that terminal only
– MestreLion
Apr 11 '13 at 8:32
@MestreLion - you are right. I was mentioning it for convenience for the current terminal. Forgot to add that.
– Matt H
Apr 18 '13 at 1:18
What if I already have something in PATH? Could I append to it like PATHS work in Windows? For example I havePATH="$HOME/bin:$HOME/.local/bin:$PATH"
already.
– Gabriel Fair
Oct 27 '17 at 22:29
add a comment |
4
Make thatexport PATH="$PATH:/usr/foo"
, in case you ever have spaces or other special characters in$PATH
.
– Gilles
Sep 6 '10 at 19:52
3
You can reload the current environment without logging out by typing ". ~/.profile"
– Matt H
Sep 7 '10 at 2:30
1
@MattH: no you can't. if you source~/.profile
in a given terminal, it will be effective for that terminal only
– MestreLion
Apr 11 '13 at 8:32
@MestreLion - you are right. I was mentioning it for convenience for the current terminal. Forgot to add that.
– Matt H
Apr 18 '13 at 1:18
What if I already have something in PATH? Could I append to it like PATHS work in Windows? For example I havePATH="$HOME/bin:$HOME/.local/bin:$PATH"
already.
– Gabriel Fair
Oct 27 '17 at 22:29
4
4
Make that
export PATH="$PATH:/usr/foo"
, in case you ever have spaces or other special characters in $PATH
.– Gilles
Sep 6 '10 at 19:52
Make that
export PATH="$PATH:/usr/foo"
, in case you ever have spaces or other special characters in $PATH
.– Gilles
Sep 6 '10 at 19:52
3
3
You can reload the current environment without logging out by typing ". ~/.profile"
– Matt H
Sep 7 '10 at 2:30
You can reload the current environment without logging out by typing ". ~/.profile"
– Matt H
Sep 7 '10 at 2:30
1
1
@MattH: no you can't. if you source
~/.profile
in a given terminal, it will be effective for that terminal only– MestreLion
Apr 11 '13 at 8:32
@MattH: no you can't. if you source
~/.profile
in a given terminal, it will be effective for that terminal only– MestreLion
Apr 11 '13 at 8:32
@MestreLion - you are right. I was mentioning it for convenience for the current terminal. Forgot to add that.
– Matt H
Apr 18 '13 at 1:18
@MestreLion - you are right. I was mentioning it for convenience for the current terminal. Forgot to add that.
– Matt H
Apr 18 '13 at 1:18
What if I already have something in PATH? Could I append to it like PATHS work in Windows? For example I have
PATH="$HOME/bin:$HOME/.local/bin:$PATH"
already.– Gabriel Fair
Oct 27 '17 at 22:29
What if I already have something in PATH? Could I append to it like PATHS work in Windows? For example I have
PATH="$HOME/bin:$HOME/.local/bin:$PATH"
already.– Gabriel Fair
Oct 27 '17 at 22:29
add a comment |
To reload .profile and take changes effects without logout/login, run:
source ~/.profile
add a comment |
To reload .profile and take changes effects without logout/login, run:
source ~/.profile
add a comment |
To reload .profile and take changes effects without logout/login, run:
source ~/.profile
To reload .profile and take changes effects without logout/login, run:
source ~/.profile
answered Dec 8 '15 at 10:43
Bruno FreitasBruno Freitas
493
493
add a comment |
add a comment |
You can add the path to /etc/environment
, but be aware that no shell expansions will work; the variable will be set to literally the characters you enter.
Out of the two methods(adding export command in .profile and adding full path name to PATH in etc/environment), which should be preferred?
– Rohan Bhatia
Jan 3 '18 at 13:14
add a comment |
You can add the path to /etc/environment
, but be aware that no shell expansions will work; the variable will be set to literally the characters you enter.
Out of the two methods(adding export command in .profile and adding full path name to PATH in etc/environment), which should be preferred?
– Rohan Bhatia
Jan 3 '18 at 13:14
add a comment |
You can add the path to /etc/environment
, but be aware that no shell expansions will work; the variable will be set to literally the characters you enter.
You can add the path to /etc/environment
, but be aware that no shell expansions will work; the variable will be set to literally the characters you enter.
edited Jun 3 '17 at 15:42
Zanna
50.9k13136241
50.9k13136241
answered Sep 8 '10 at 12:28
sagarchalisesagarchalise
18.1k105974
18.1k105974
Out of the two methods(adding export command in .profile and adding full path name to PATH in etc/environment), which should be preferred?
– Rohan Bhatia
Jan 3 '18 at 13:14
add a comment |
Out of the two methods(adding export command in .profile and adding full path name to PATH in etc/environment), which should be preferred?
– Rohan Bhatia
Jan 3 '18 at 13:14
Out of the two methods(adding export command in .profile and adding full path name to PATH in etc/environment), which should be preferred?
– Rohan Bhatia
Jan 3 '18 at 13:14
Out of the two methods(adding export command in .profile and adding full path name to PATH in etc/environment), which should be preferred?
– Rohan Bhatia
Jan 3 '18 at 13:14
add a comment |
Youcan modify the .bashrc
file in your $HOME
directory.
At the very end of this file, add the line:
export PATH="$HOME/directory_to_include_in_path/:$PATH"
You can also modify the .profile
file, also in your $HOME
directory, including the following line:
PATH="$HOME/directory_to_include_in_path/:$PATH"
This worked for me.
2
I don't see what this adds to the other answers which explain more thoroughly.
– Zanna
Jun 3 '17 at 15:47
add a comment |
Youcan modify the .bashrc
file in your $HOME
directory.
At the very end of this file, add the line:
export PATH="$HOME/directory_to_include_in_path/:$PATH"
You can also modify the .profile
file, also in your $HOME
directory, including the following line:
PATH="$HOME/directory_to_include_in_path/:$PATH"
This worked for me.
2
I don't see what this adds to the other answers which explain more thoroughly.
– Zanna
Jun 3 '17 at 15:47
add a comment |
Youcan modify the .bashrc
file in your $HOME
directory.
At the very end of this file, add the line:
export PATH="$HOME/directory_to_include_in_path/:$PATH"
You can also modify the .profile
file, also in your $HOME
directory, including the following line:
PATH="$HOME/directory_to_include_in_path/:$PATH"
This worked for me.
Youcan modify the .bashrc
file in your $HOME
directory.
At the very end of this file, add the line:
export PATH="$HOME/directory_to_include_in_path/:$PATH"
You can also modify the .profile
file, also in your $HOME
directory, including the following line:
PATH="$HOME/directory_to_include_in_path/:$PATH"
This worked for me.
edited Jun 3 '17 at 15:44
Zanna
50.9k13136241
50.9k13136241
answered Jun 3 '17 at 14:23
Denner VieiraDenner Vieira
1
1
2
I don't see what this adds to the other answers which explain more thoroughly.
– Zanna
Jun 3 '17 at 15:47
add a comment |
2
I don't see what this adds to the other answers which explain more thoroughly.
– Zanna
Jun 3 '17 at 15:47
2
2
I don't see what this adds to the other answers which explain more thoroughly.
– Zanna
Jun 3 '17 at 15:47
I don't see what this adds to the other answers which explain more thoroughly.
– Zanna
Jun 3 '17 at 15:47
add a comment |
Going through the basics, I will suggest the following steps:
1. It's recommended to set environment variables in /etc/environment
2. Open the file as superuser in an editor as it's a read only file e.g. gedit:
gksu gedit /etc/environment
3. System will need password to open it in editable mode. Enter your superuser password and get file opened in a new gedit window.
4. Add new line at the end of file with
export PATH=$PATH:/usr/local/foo
5. Save and close the window. It will get command back to terminal.
6. Refresh the environment by running the following command:
. /etc/environment
7. You may check by executing the following command:
echo $PATH
This is incorrect and will not work. Parameter expansion is not performed in/etc/environment
– Zanna
Jun 3 '17 at 15:16
add a comment |
Going through the basics, I will suggest the following steps:
1. It's recommended to set environment variables in /etc/environment
2. Open the file as superuser in an editor as it's a read only file e.g. gedit:
gksu gedit /etc/environment
3. System will need password to open it in editable mode. Enter your superuser password and get file opened in a new gedit window.
4. Add new line at the end of file with
export PATH=$PATH:/usr/local/foo
5. Save and close the window. It will get command back to terminal.
6. Refresh the environment by running the following command:
. /etc/environment
7. You may check by executing the following command:
echo $PATH
This is incorrect and will not work. Parameter expansion is not performed in/etc/environment
– Zanna
Jun 3 '17 at 15:16
add a comment |
Going through the basics, I will suggest the following steps:
1. It's recommended to set environment variables in /etc/environment
2. Open the file as superuser in an editor as it's a read only file e.g. gedit:
gksu gedit /etc/environment
3. System will need password to open it in editable mode. Enter your superuser password and get file opened in a new gedit window.
4. Add new line at the end of file with
export PATH=$PATH:/usr/local/foo
5. Save and close the window. It will get command back to terminal.
6. Refresh the environment by running the following command:
. /etc/environment
7. You may check by executing the following command:
echo $PATH
Going through the basics, I will suggest the following steps:
1. It's recommended to set environment variables in /etc/environment
2. Open the file as superuser in an editor as it's a read only file e.g. gedit:
gksu gedit /etc/environment
3. System will need password to open it in editable mode. Enter your superuser password and get file opened in a new gedit window.
4. Add new line at the end of file with
export PATH=$PATH:/usr/local/foo
5. Save and close the window. It will get command back to terminal.
6. Refresh the environment by running the following command:
. /etc/environment
7. You may check by executing the following command:
echo $PATH
answered Jan 22 '16 at 20:00
MacMac
11
11
This is incorrect and will not work. Parameter expansion is not performed in/etc/environment
– Zanna
Jun 3 '17 at 15:16
add a comment |
This is incorrect and will not work. Parameter expansion is not performed in/etc/environment
– Zanna
Jun 3 '17 at 15:16
This is incorrect and will not work. Parameter expansion is not performed in
/etc/environment
– Zanna
Jun 3 '17 at 15:16
This is incorrect and will not work. Parameter expansion is not performed in
/etc/environment
– Zanna
Jun 3 '17 at 15:16
add a comment |
Thanks for contributing an answer to Ask Ubuntu!
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2faskubuntu.com%2fquestions%2f3744%2fhow-do-i-modify-my-path-so-that-the-changes-are-available-in-every-terminal-sess%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown