Scheduled Maintenance: We are aware of an issue with Google, AOL, and Yahoo services as email providers which are blocking new registrations. We are trying to fix the issue and we have several internal and external support tickets in process to resolve the issue. Please see: viewtopic.php?t=158230

 

 

 

Debian 11 set path at login ?

If none of the specific sub-forums seem right for your thread, ask here.
Message
Author
mm3100
Posts: 336
Joined: 2020-10-21 21:39
Has thanked: 8 times
Been thanked: 13 times

Re: Debian 11 set path at login ?

#21 Post by mm3100 »

Now to make even more confusion, I have checked my path
/home/mm/bin:/usr/local/bin:/usr/bin:/bin:/usr/local/games:/usr/games

Looking in .bashrc I didn't had to add anything. And only configuration for /home/user/bin is in .profile. I will create .local/bin and see if it gets added as well, as is described by in .profile.

/home/mm/.local/bin:/home/mm/bin:/usr/local/bin:/usr/bin:/bin:/usr/local/games:/usr/games


Okay, logged out and back in, and .local/bin was added to my path as it should. I have tested it in tty and using konsole. I don't know where else would path could possibly be added, no other mention in my home directory. I am using KDE so there is possibility it is adding it somehow where I don't know from.

So far it seems to me that it is working as intended.

User avatar
ticojohn
Posts: 1284
Joined: 2009-08-29 18:10
Location: Costa Rica
Has thanked: 21 times
Been thanked: 44 times

Re: Debian 11 set path at login ?

#22 Post by ticojohn »

mm3100 wrote: 2021-08-30 19:38 Now to make even more confusion, I have checked my path
/home/mm/bin:/usr/local/bin:/usr/bin:/bin:/usr/local/games:/usr/games

Looking in .bashrc I didn't had to add anything. And only configuration for /home/user/bin is in .profile. I will create .local/bin and see if it gets added as well, as is described by in .profile.

/home/mm/.local/bin:/home/mm/bin:/usr/local/bin:/usr/bin:/bin:/usr/local/games:/usr/games


Okay, logged out and back in, and .local/bin was added to my path as it should. I have tested it in tty and using konsole. I don't know where else would path could possibly be added, no other mention in my home directory. I am using KDE so there is possibility it is adding it somehow where I don't know from.

So far it seems to me that it is working as intended.
Yes it is more confusing. :? I know that with XFCE and LIGHTDM, $HOME/bin is not getting added to PATH. And furthermore it appears that ~/.profile is not being executed. As Alice said, curiouser and curiouser.
I am not irrational, I'm just quantum probabilistic.

User avatar
sunrat
Administrator
Administrator
Posts: 6382
Joined: 2006-08-29 09:12
Location: Melbourne, Australia
Has thanked: 115 times
Been thanked: 456 times

Re: Debian 11 set path at login ?

#23 Post by sunrat »

mm3100 wrote: 2021-08-30 19:38Okay, logged out and back in, and .local/bin was added to my path as it should. I have tested it in tty and using konsole. I don't know where else would path could possibly be added, no other mention in my home directory. I am using KDE so there is possibility it is adding it somehow where I don't know from.

So far it seems to me that it is working as intended.
Sorry I can't solve the mystery but just want to add that I also use KDE, and ~/bin/ and ~/local/bin are added to PATH after creating those directories so working as intended. The only entry I find to enable this is in ~/.profile

So it works for 2 KDE users and not for an Xfce user. Maybe a DE specific issue?
“ computer users can be divided into 2 categories:
Those who have lost data
...and those who have not lost data YET ”
Remember to BACKUP!

Dai_trying
Posts: 1100
Joined: 2016-01-07 12:25
Has thanked: 5 times
Been thanked: 16 times

Re: Debian 11 set path at login ?

#24 Post by Dai_trying »

One thing you could try is to add a line to each config file you are running like this

Code: Select all

logger "running bashrc now"
obviously you should change bashrc in this command to whichever config file you want to follow, and then simply look at /var/log/syslog to see which files are run when your terminal is opened or script is run.

p.s. remember to remove these lines after your testing unless you want them running permanently.

User avatar
ticojohn
Posts: 1284
Joined: 2009-08-29 18:10
Location: Costa Rica
Has thanked: 21 times
Been thanked: 44 times

Re: Debian 11 set path at login ?

#25 Post by ticojohn »

Dai_trying wrote: 2021-08-31 10:41 One thing you could try is to add a line to each config file you are running like this

Code: Select all

logger "running bashrc now"
obviously you should change bashrc in this command to whichever config file you want to follow, and then simply look at /var/log/syslog to see which files are run when your terminal is opened or script is run.

p.s. remember to remove these lines after your testing unless you want them running permanently.
Thanks @Dai_trying. I actually did something to check that ~/.profile executes at login. It appears that with my system configuration, XFCE and lightdm, ~/.profile does not execute. Very strange indeed. But maybe I am missing something. I'm not going to worry about it as this was all an effort to help the OP. And the solution I gave him earlier was to add some code at the end of the ~/.bashrc file. I think that takes care of the OP's need, although it doesn't address the issue of ~/.profile not running at login.
I am not irrational, I'm just quantum probabilistic.

cfb
Posts: 52
Joined: 2017-01-08 16:39
Been thanked: 5 times

Re: Debian 11 set path at login ?

#26 Post by cfb »

Please read this wiki page: https://wiki.debian.org/EnvironmentVariables
It will explain how PATH is set depending on how you log in.

User avatar
ticojohn
Posts: 1284
Joined: 2009-08-29 18:10
Location: Costa Rica
Has thanked: 21 times
Been thanked: 44 times

Re: Debian 11 set path at login ?

#27 Post by ticojohn »

I am going to make one last comment on this. Earlier I said I found an article saying that $HOME/.profile and $HOME/.bashrc only execute when the user logs in using an interactive shell. Well I just saw the following code in $HOME/.bashrc in my installation.

Code: Select all

# If not running interactively, don't do anything
case $- in
    *i*) ;;
      *) return;;
esac
Now MAYBE, different desktops and managers do things differently. But at least in the case of XFCE and lightdm it would seem that $HOME/.profile and $HOME/.bashrc are not executed when logging in graphically.

However, I just blew my conclusion out the door. Why? Because adding code at the end of ~/.bashrc to include $HOME/bin in PATH does execute. So obviously ~/.bashrc is getting executed.

Will somebody please slap me up the side of the head and tell me to STFU? :mrgreen:
I am not irrational, I'm just quantum probabilistic.

gh4rock
Posts: 13
Joined: 2021-08-29 13:10

Re: Debian 11 set path at login ?

#28 Post by gh4rock »

Thanks for the link to the wiki....
Please read this wiki page: https://wiki.debian.org/EnvironmentVariables
I am using Debian 11, Cinnamon desktop for AMD64.
Since users are provided "/bin/bash" as the default login shell, adding the $HOME/bin to .bashrc seems to be the best work around to me.
The login shell will execute .bash_login, but the PATH established there does not survive the completion of the login process.
Does anyone know where $HOME is first setup for the user ?

User avatar
Bloom
df -h | grep > 90TiB
df -h | grep > 90TiB
Posts: 503
Joined: 2017-11-11 12:23
Been thanked: 26 times

Re: Debian 11 set path at login ?

#29 Post by Bloom »

Please read the wiki suggested above. It explains that .bashrc and .profile are NOT executed after a graphical login. You should create or edit .xessionrc or .xinitrc to include a reference to .profile like this:

Code: Select all

if [[ -f ~/.profile ]]; then
     . ~/.profile
 fi
Then make sure .profile contains all your environment variables including:

Code: Select all

export PATH=$PATH:~/bin

halpdesk
Posts: 1
Joined: 2021-10-10 17:16

Re: Debian 11 set path at login ?

#30 Post by halpdesk »

Hi!
Created an account here just to let you know how I solved it on my newly installed Debian 11 (2021 October the 10th).
I'll also add (for future google reference) that this is how you can run flatpak and snap bins from your application runner, or "Run application" (Alt+F2), by adding their respective bin paths to PATH.

Thanks to @Bloom (and everyone else) above for finally pointing out what needs to be done.

1. Create the .xsessionrc file with this content:

Code: Select all

#!/bin/sh
. ~/.profile
2. Add any paths to PATH in your .profile file, and remember to export PATH in the end:

Code: Select all

# Snap
if [ -d "/snap/bin" ] ; then
    PATH="/snap/bin:$PATH"
fi

export PATH=$PATH:~/bin
That's it!
The files .bashrc, .profile or .bash_profile, are as mentioned above in the thread not read by a graphical session. If you want to know more about the xsession files, see this link:
https://unix.stackexchange.com/question ... xsessionrc

varond
Posts: 1
Joined: 2022-01-08 23:16

Re: Debian 11 set path at login ?

#31 Post by varond »

Hello everybody! Sorry for my bad english. Found a global solution to the problem, adding $ path after logging into X11. I created the following script in /etc/X11/Xsession.d/100basrc_file

Code: Select all

#!/bin/bash
. ~/.bashrc
. /etc/profile
After rebooting, and entering X11, the path variable is added automatically.

_pitch
Posts: 1
Joined: 2023-02-18 17:12

Re: Debian 11 set path at login ?

#32 Post by _pitch »

as @ticojohn so empathetically mentioned
Earlier I said I found an article saying that $HOME/.profile and $HOME/.bashrc only execute when the user logs in using an interactive shell
and logging in with xfce and lightdm is obvoiusly not counted as an interactive shell
(proven that that rule doesn't imply $HOME/.bashrc)
However, I just blew my conclusion out the door. Why? Because adding code at the end of ~/.bashrc to include $HOME/bin in PATH does execute. So obviously ~/.bashrc is getting executed.
how come $HOME/.profile is sourced in xubuntu non-interactive login, using lightdm and xfce and not in debian?
obviously it's possible to source $HOME/.profile without manually adding any .xsessionrc
i'm sure it's a bug in debian lightdm/xfce setup as it's possible to circumvent in xubuntu
i'm not sure what's the difference between the different setups but maybe i'll find out some day

User avatar
fabien
Forum Helper
Forum Helper
Posts: 604
Joined: 2019-12-03 12:51
Location: Anarres (Toulouse, France actually)
Has thanked: 60 times
Been thanked: 141 times

Re: Debian 11 set path at login ?

#33 Post by fabien »

_pitch wrote: 2023-02-18 17:41how come $HOME/.profile is sourced in xubuntu non-interactive login, using lightdm and xfce and not in debian?
this is how I worked around this:

Code: Select all

$> cat ~/.config/xfce4/xinitrc 
#!/usr/bin/env sh

## workaround to enable custom PATH in XFCE with lightdm (which has PATH hardcoded)
## see /usr/bin/startxfce4
## http://xfce.10915.n7.nabble.com/adapted-PATH-not-available-for-GUI-td43586.html

if [ -d "$HOME/.local/bin" ] ; then
   export PATH="$HOME/.local/bin:$PATH"
fi

. /etc/xdg/xfce4/xinitrc


patrickprucha
Posts: 1
Joined: 2023-03-15 20:57

Re: Debian 11 set path at login ?

#34 Post by patrickprucha »

Actually after reviewing the posts, and confirming
a) no .bash_login
b) no .bash_profile
c) yes .profile
d) yes .profile does include the if statement about "$HOME/bin" but in the end...
e) the PATH is equal to "/usr/local/bin:/usr/bin:/bin:/usr/local/games:/usr/games" , even after i modified the /etc flavours and remove the folder /usr/games, and rebooted.... i still get games in the freaking path!!!!
i agree that the easiest way to do this is to use your .bashrc file and if you want to include directories in the path, use
1) export PATH='/home/user/bin:$PATH' or
2) the code as you suggested.

t

User avatar
kent_dorfman766
Posts: 529
Joined: 2022-12-16 06:34
Location: socialist states of america
Has thanked: 56 times
Been thanked: 69 times

Re: Debian 11 set path at login ?

#35 Post by kent_dorfman766 »

search for and use the pathmunge() shell function and make sure it and the subsequent path expansion setting are in every possible shell shartup file you can find. different system access methods invoke differing shell startup scripts.

Post Reply