hello, I would like to change the $PATH environment variable permanently, to be able to execute a program more quickly. I have tried adding a new line: export PATH=$PATH:/my/path , to my .bashrc . When I log in again, I see that $PATH is now: $PATH:/my/path/:/my/path, my directory has been appended twice. I don't know exactly what the "export" command actually does, so I am lost here. thanks for your help.
On Fri, Jun 24, 2022 at 9:09 AM Anil F Duggirala anilduggirala@fastmail.fm wrote:
hello, I would like to change the $PATH environment variable permanently, to be able to execute a program more quickly. I have tried adding a new line: export PATH=$PATH:/my/path , to my .bashrc . When I log in again, I see that $PATH is now: $PATH:/my/path/:/my/path, my directory has been appended twice. I don't know exactly what the "export" command actually does, so I am lost here.
I expect many other command-line tools are also unknown to you. Adjusting the PATH setting may not be the best solution if you just want to run one program. You can add your program to the GUI configuration to start it with an icon, put a symbolic link to the program in a directory that is already in the PATH, such as $HOME/bin, create a shell script that runs the program with additional environment settings, and many more depending on how the program is used.
Once your linux usage moves beyond web browsing it is important to master some basic command-line/shell tools. There are many dangerously misleading youtube tutorials (avoid those that claim to be easy or fast!) and a few that are excellent, but I suggest starting with LinuxCommand.org as it has been used by many people for years.
If the directory you want to add to the PATH contains a single program, other methods are probably more appropriate. The reason the PATH is added twice is that ~/.bashrc gets run each time bash is invoked. If you log in on a text console you normally see one entry in the PATH. If you are in a bash terminal session and see 2 entries, starting bash again will give 3 entries.
On Fedora, /etc/profile defines a shell function called pathmunge that checks to see if a directory is already in the PATH before adding it to the PATH.
thanks for your help.
Trick is add this around the path add.
If [ $path_add -ne 1 ] ; then Path addition code Path_add=1 Fi
That only runs it once.
On Fri, Jun 24, 2022, 4:09 AM Anil F Duggirala anilduggirala@fastmail.fm wrote:
hello, I would like to change the $PATH environment variable permanently, to be able to execute a program more quickly. I have tried adding a new line: export PATH=$PATH:/my/path , to my .bashrc . When I log in again, I see that $PATH is now: $PATH:/my/path/:/my/path, my directory has been appended twice. I don't know exactly what the "export" command actually does, so I am lost here. thanks for your help. _______________________________________________ users mailing list -- users@lists.fedoraproject.org To unsubscribe send an email to users-leave@lists.fedoraproject.org Fedora Code of Conduct: https://docs.fedoraproject.org/en-US/project/code-of-conduct/ List Guidelines: https://fedoraproject.org/wiki/Mailing_list_guidelines List Archives: https://lists.fedoraproject.org/archives/list/users@lists.fedoraproject.org Do not reply to spam on the list, report it: https://pagure.io/fedora-infrastructure
On Fri, Jun 24, 2022 at 12:36 PM Roger Heflin rogerheflin@gmail.com wrote:
Trick is add this around the path add.
If [ $path_add -ne 1 ] ; then Path addition code Path_add=1 Fi
That only runs it once.
This clutters up the environment. I often encountered weird environment variables when a user had problems. Fedora's /etc/profile defininition of "pathmunge" checks to see if the proposed entry is already present:
pathmunge () { case ":${PATH}:" in *:"$1":*) ;; *) if [ "$2" = "after" ] ; then PATH=$PATH:$1 else PATH=$1:$PATH fi esac }
Exercise left to the reader: modify path_munge to only add directories that actually exist on the system.
I have seen environments with:
"some_application_version_N/bin:...:some_application_version_1/bin:..." or "...:some_application_version_N-1/bin:...:some_application_version_N/bin: and user wonders why the new version seems to be the same as the old version.
Environment modules are handy when you want to choose a version to use on the command-line.
On Fri, Jun 24, 2022, 4:09 AM Anil F Duggirala anilduggirala@fastmail.fm wrote:
hello, I would like to change the $PATH environment variable permanently, to be able to execute a program more quickly. I have tried adding a new line: export PATH=$PATH:/my/path , to my .bashrc . When I log in again, I see that $PATH is now: $PATH:/my/path/:/my/path, my directory has been appended twice. I don't know exactly what the "export" command actually does, so I am lost here. thanks for your help. _______________________________________________ users mailing list -- users@lists.fedoraproject.org To unsubscribe send an email to users-leave@lists.fedoraproject.org Fedora Code of Conduct: https://docs.fedoraproject.org/en-US/project/code-of-conduct/ List Guidelines: https://fedoraproject.org/wiki/Mailing_list_guidelines List Archives: https://lists.fedoraproject.org/archives/list/users@lists.fedoraproject.org Do not reply to spam on the list, report it: https://pagure.io/fedora-infrastructure
users mailing list -- users@lists.fedoraproject.org To unsubscribe send an email to users-leave@lists.fedoraproject.org Fedora Code of Conduct: https://docs.fedoraproject.org/en-US/project/code-of-conduct/ List Guidelines: https://fedoraproject.org/wiki/Mailing_list_guidelines List Archives: https://lists.fedoraproject.org/archives/list/users@lists.fedoraproject.org Do not reply to spam on the list, report it: https://pagure.io/fedora-infrastructure
On Fri, 2022-06-24 at 11:49 -0300, George N. White III wrote:
You can add your program to the GUI configuration to start it with an icon, put a symbolic link to the program in a directory that is already in the PATH, such as $HOME/bin, create a shell script that runs the program with additional environment settings, and many more depending on how the program is used.
Thanks George. I know I can create a Gnome launcher to do this, but thats not really what I wanted. In Gnome, alt-F2 will open a little window that lets me issue a command line instruction (like executing a program), I like that, its fast and easy. I like the idea of just adding a symbolic link to ~/bin, that path is in my $PATH variable but the folder doesn't exist, yet.
Once your linux usage moves beyond web browsing it is important to master some basic command-line/shell tools.
Ouch, web browsing, that hurt a little.
There are many dangerously misleading youtube tutorials (avoid those that claim to be easy or fast!) and a few that are excellent, but I suggest starting with LinuxCommand.org as it has been used by many people for years.
Thanks for this reference, I will look it up. Right now I am reading a book called, How Linux Works by Brian Ward.
If the directory you want to add to the PATH contains a single program, other methods are probably more appropriate.
Ok, that makes sense.
The reason the PATH is added twice is that ~/.bashrc gets run each time bash is invoked. If you log in on a text console you normally see one entry in the PATH. If you are in a bash terminal session and see 2 entries, starting bash again will give 3 entries.
On Fedora, /etc/profile defines a shell function called pathmunge that checks to see if a directory is already in the PATH before adding it to the PATH.
Ok, I will look into pathmunge, just to learn something new. thanks a lot for this.
Anil
On Fri, Jun 24, 2022 at 07:36:00AM -0800, Roger Heflin wrote:
Trick is add this around the path add.
If [ $path_add -ne 1 ] ; then Path addition code Path_add=1 Fi
That only runs it once.
On Fri, Jun 24, 2022, 4:09 AM Anil F Duggirala anilduggirala@fastmail.fm wrote:
hello, I would like to change the $PATH environment variable permanently, to be able to execute a program more quickly. I have tried adding a new line: export PATH=$PATH:/my/path , to my .bashrc . When I log in again, I see that $PATH is now: $PATH:/my/path/:/my/path, my directory has been appended twice. I don't know exactly what the "export" command actually does, so I am lost here. thanks for your help.
Conceptually similar to Roger's approach, I set an environment variable "OrigPATH" to the initial PATH then assign PATH based on OrigPATH.
# save a copy of the original path to modify export OrigPATH=${OrigPATH:-$PATH} # adjust PATH from OrigPATH to my tastes export PATH=$HOME/bin:$OrigPATH:/my/path
On Fri, Jun 24, 2022 at 6:04 PM Jon LaBadie jonfu@jgcomp.com wrote:
On Fri, Jun 24, 2022 at 07:36:00AM -0800, Roger Heflin wrote:
Trick is add this around the path add.
If [ $path_add -ne 1 ] ; then Path addition code Path_add=1 Fi
That only runs it once.
On Fri, Jun 24, 2022, 4:09 AM Anil F Duggirala <anilduggirala@fastmail.fm
wrote:
hello, I would like to change the $PATH environment variable permanently, to be able to execute a program more quickly. I have tried adding a new line: export PATH=$PATH:/my/path , to my .bashrc . When I log in again, I see that $PATH is now: $PATH:/my/path/:/my/path, my directory has been appended twice. I don't know exactly what the "export" command actually does, so I am lost here. thanks for your help.
Conceptually similar to Roger's approach, I set an environment variable "OrigPATH" to the initial PATH then assign PATH based on OrigPATH.
# save a copy of the original path to modify export OrigPATH=${OrigPATH:-$PATH} # adjust PATH from OrigPATH to my tastes export PATH=$HOME/bin:$OrigPATH:/my/path
Environment modules preserves the current environment and then adds or modifies environment variables according to a "modulefile". The original has been around for decades, there is now a lua version. Fedora uses environment modules when building rpm's that support more than one choice for supporting libraries. See:
% ls /usr/share/modulefiles/mpi mpich-x86_64 openmpi-x86_64
On 24 Jun 2022, at 13:10, Anil F Duggirala anilduggirala@fastmail.fm wrote:
hello, I would like to change the $PATH environment variable permanently, to be able to execute a program more quickly. I have tried adding a new line: export PATH=$PATH:/my/path , to my .bashrc .
See PATH in .bash_profile not .bashrc. Because you want it set once, not every time a new subprocess starts.
When you start a Terminal it should be setup to start a login shell.
Barry
When I log in again, I see that $PATH is now: $PATH:/my/path/:/my/path, my directory has been appended twice. I don't know exactly what the "export" command actually does, so I am lost here. thanks for your help. _______________________________________________ users mailing list -- users@lists.fedoraproject.org To unsubscribe send an email to users-leave@lists.fedoraproject.org Fedora Code of Conduct: https://docs.fedoraproject.org/en-US/project/code-of-conduct/ List Guidelines: https://fedoraproject.org/wiki/Mailing_list_guidelines List Archives: https://lists.fedoraproject.org/archives/list/users@lists.fedoraproject.org Do not reply to spam on the list, report it: https://pagure.io/fedora-infrastructure
On 24 Jun 2022, at 16:36, Roger Heflin rogerheflin@gmail.com wrote:
Trick is add this around the path add.
If [ $path_add -ne 1 ] ; then Path addition code Path_add=1 Fi
That only runs it once.
This is a work around for using ,bashrc when .bash_profile is where this should be done.
Barry
On Fri, Jun 24, 2022, 4:09 AM Anil F Duggirala anilduggirala@fastmail.fm wrote: hello, I would like to change the $PATH environment variable permanently, to be able to execute a program more quickly. I have tried adding a new line: export PATH=$PATH:/my/path , to my .bashrc . When I log in again, I see that $PATH is now: $PATH:/my/path/:/my/path, my directory has been appended twice. I don't know exactly what the "export" command actually does, so I am lost here. thanks for your help. _______________________________________________ users mailing list -- users@lists.fedoraproject.org To unsubscribe send an email to users-leave@lists.fedoraproject.org Fedora Code of Conduct: https://docs.fedoraproject.org/en-US/project/code-of-conduct/ List Guidelines: https://fedoraproject.org/wiki/Mailing_list_guidelines List Archives: https://lists.fedoraproject.org/archives/list/users@lists.fedoraproject.org Do not reply to spam on the list, report it: https://pagure.io/fedora-infrastructure
users mailing list -- users@lists.fedoraproject.org To unsubscribe send an email to users-leave@lists.fedoraproject.org Fedora Code of Conduct: https://docs.fedoraproject.org/en-US/project/code-of-conduct/ List Guidelines: https://fedoraproject.org/wiki/Mailing_list_guidelines List Archives: https://lists.fedoraproject.org/archives/list/users@lists.fedoraproject.org Do not reply to spam on the list, report it: https://pagure.io/fedora-infrastructure
On Fri, Jun 24, 2022 at 7:28 PM Barry barry@barrys-emacs.org wrote:
On 24 Jun 2022, at 16:36, Roger Heflin rogerheflin@gmail.com wrote:
Trick is add this around the path add.
If [ $path_add -ne 1 ] ; then Path addition code Path_add=1 Fi
That only runs it once.
This is a work around for using ,bashrc when .bash_profile is where this should be done.
I think that advice goes back to a time before modern GUI's. Now many users have never encountered a terminal, and distros vary widely in the use of ~/.bashrc, ~/.bash_profle, and ~/.profile.
On my Fedora 35 box, ~/.bash_profile is:
----------------------------------ser # .bash_profile
# Get the aliases and functions if [ -f ~/.bashrc ]; then . ~/.bashrc fi
# User specific environment and startup programs ---------------------------
Some distros have complicated ~/.bashrc or `/.bash_profile files with a section devoted to interactive sessions. This led to issues where users added settings in the wrong section. I often ask users to run a failing command in a terminal where they may see messages that their GUI tools hide, but getting different behaviours between GUI and terminal has become a problem.
On 25 Jun 2022, at 12:36, George N. White III gnwiii@gmail.com wrote:
On Fri, Jun 24, 2022 at 7:28 PM Barry barry@barrys-emacs.org wrote:
On 24 Jun 2022, at 16:36, Roger Heflin rogerheflin@gmail.com wrote:
Trick is add this around the path add.
If [ $path_add -ne 1 ] ; then Path addition code Path_add=1 Fi
That only runs it once.
This is a work around for using ,bashrc when .bash_profile is where this should be done.
I think that advice goes back to a time before modern GUI's. Now many users have never encountered a terminal, and distros vary widely in the use of ~/.bashrc, ~/.bash_profle, and ~/.profile.
Actually they are fixing the problem of inheriting .bash_profile from the login to the gui session to running the shell on login mode. So no this is not out of date advice.
On my Fedora 35 box, ~/.bash_profile is:
----------------------------------ser # .bash_profile
# Get the aliases and functions if [ -f ~/.bashrc ]; then . ~/.bashrc fi
That has been required since the beginning of time.
You always source .bashrc in the profile.
The reason that you do not set important things in the .bashrc is that if you do that you cannot override them from the command line.
For example if you set PATH in .bashrc you cannot then change for any sub shells from the command line.
Barry
# User specific environment and startup programs
Some distros have complicated ~/.bashrc or `/.bash_profile files with a section devoted to interactive sessions. This led to issues where users added settings in the wrong section. I often ask users to run a failing command in a terminal where they may see messages that their GUI tools hide, but getting different behaviours between GUI and terminal has become a problem.
-- George N. White III
users mailing list -- users@lists.fedoraproject.org To unsubscribe send an email to users-leave@lists.fedoraproject.org Fedora Code of Conduct: https://docs.fedoraproject.org/en-US/project/code-of-conduct/ List Guidelines: https://fedoraproject.org/wiki/Mailing_list_guidelines List Archives: https://lists.fedoraproject.org/archives/list/users@lists.fedoraproject.org Do not reply to spam on the list, report it: https://pagure.io/fedora-infrastructure