You are not logged in.
I use Arch Linux with KDE Plasma. I would like to add the directory /home/jm/bin to the $PATH variable. I know I can add "export PATH="${PATH}:/home/jm/bin"" at the end of the .bashrc file, but it occurred to me to manually add the /home/jm/bin path to the configuration file. I checked everything that came to my mind, such as etc/bash.bashrc, but I can't find the configuration for the $PATH variable, which currently looks like this:
/usr/local/sbin:/usr/local/bin:/usr/bin:/var/lib/flatpak/exports/bin:/usr/lib/jvm/default/bin:/usr/bin/site_perl:/usr/bin/vendor_perl:/usr/bin/core_perlDefining variables didn't help.
Offline
The systemwide $PATH is setup in /etc/profile .
You typically DON'T add user-specific search folders there
Disliking systemd intensely, but not satisfied with alternatives so focusing on taming systemd.
clean chroot building not flexible enough ?
Try clean chroot manager by graysky
Offline
It's an environment variable. It's carried in memory (the environment) of every running process. There is no file in which it is stored*. It can be set / appeneded to in any script file that is sourced / executed as outlined in the link you posted.
There are, however, some good (and not so good) practices of where to set / export it. Your ~/.bashrc is generally not a good place to set / export PATH; your ~/.bash_profile is. (This too is covered in the wiki page you linked to.)
*note: technically this chunk of the processes memory is represented by a pseudo-file at /proc/$PID/environ, but these cannot be edited to change the PATH variable - and even if they could it would only change it for that running process.
Last edited by Trilby (2023-07-23 12:23:28)
"UNIX is simple and coherent" - Dennis Ritchie; "GNU's Not Unix" - Richard Stallman
Online
Thank you.
My current cat bash_profile output is:
$ cat .bash_profile
#
# ~/.bash_profile
#
[[ -f ~/.bashrc ]] && . ~/.bashrcShould I just change it to:
#
# ~/.bash_profile
#
[[ -f ~/.bashrc ]] && . ~/.bashrc
export PATH="${PATH}:/home/jm/bin"?
Offline
If that variable is used from anything in .bashrc (or from anything called from within .bashrc) it would have to be first. And even if this isn't the case, now, it'd be far better practice to set / export the variable first in order to avoid future surprises:
export PATH="${PATH}:/home/jm/bin"
[[ -f ~/.bashrc ]] && . ~/.bashrcBut if you are using a display manager, be sure to see the comments about that in the wiki page.
"UNIX is simple and coherent" - Dennis Ritchie; "GNU's Not Unix" - Richard Stallman
Online
That will cover bash's but not necessariy other shells.
Sth. like
if [ -d ~/bin ] ; then
PATH=$HOME/bin:"${PATH}"
fiin ~/.profile would be more common, also nb. the order which will allow you to shadow global executables in ~/bin
Edit: fckagain.
Last edited by seth (2023-07-23 13:16:08)
Offline
Just as a general comment, I found it to be an enlightening process to trace the configurations files, or startup scripts, involved in starting my shell; it helps understand how things fit together and makes it clearer where to put customizations.
I use Bash, Xfce and Lightdm, and there's a truckload of places to add stuff during startup, but basically it goes like this:
/etc/lightdm/Xsession
/etc/profile
/etc/profile.d/*
~/.xprofile
/etc/X11/xinit/xinitrc.d/*
startxfce4That brings up Xfce, and any environment variables set by this time will be valid for anything started from the Xfce session. Therefore I place an umask setting in .xprofile, so any program that creates files will use the correct umask ![]()
When I start a bash terminal, this is what happens:
/etc/profile
/etc/profile.d/*
/etc/bash.bashrc
~/.bash_profile
~/.bashrc
~/.bash_aliasesThe reason ~/.bash_profile is run is that I have ticked the checkbox in Xfce Terminal to run the shell as a login shell. If I hadn't done that, then only ~/.bashrc would have been run - which is why I put my PATH in ~/.bashrc (along with umask again, to correct the setting from /etc/profile, which overrides my .xprofile umask) ![]()
I have cleaned up my stuff a little, so this can easily be more complex.
It's useful to read up on the configuration of Bash and Lightdm or whatever you're using, just to make sure that you understand what you do, whatever you do!
And if anybody wants to bash my bash-settings, please do - it's all about learning ![]()
Edit: Just tidying up a little
Last edited by Ferdinand (2023-07-24 08:41:41)
Offline