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 default $PATH where it comes from?
Debian default $PATH where it comes from?
Hello I'm curious where the default $PATH variable comes from which contains /games/ among others. I was trying to remove it but unsuccessfully. I found that PATH is set in:
/etc/login.defs
/etc/profile
/etc/environment
some .bashrc, .bash_profile, .config files
I removed entry from each file, then reset PC but it still shows `/usr/local/bin:/usr/bin:/bin:/usr/local/games:/usr/games` on echo $PATH.
I know I can just override it but I'm really curious where it comes from.
EDIT: I'm using 4.9.0-8-amd64 #1 SMP Debian 4.9.110-3+deb9u5 (2018-09-30) x86_64 GNU/Linux
/etc/login.defs
/etc/profile
/etc/environment
some .bashrc, .bash_profile, .config files
I removed entry from each file, then reset PC but it still shows `/usr/local/bin:/usr/bin:/bin:/usr/local/games:/usr/games` on echo $PATH.
I know I can just override it but I'm really curious where it comes from.
EDIT: I'm using 4.9.0-8-amd64 #1 SMP Debian 4.9.110-3+deb9u5 (2018-09-30) x86_64 GNU/Linux
- Head_on_a_Stick
- Posts: 14114
- Joined: 2014-06-01 17:46
- Location: London, England
- Has thanked: 81 times
- Been thanked: 133 times
Re: Debian default $PATH where it comes from?
PATH is set in ~/.profile
~/.profile is copied from /etc/skel/.profile (provided by the bash package) by the adduser(8) program when a new user is created.
EDIT: note though that bash will not read ~/.profile if ~/.bash_profile exists.
~/.profile is copied from /etc/skel/.profile (provided by the bash package) by the adduser(8) program when a new user is created.
EDIT: note though that bash will not read ~/.profile if ~/.bash_profile exists.
deadbang
Re: Debian default $PATH where it comes from?
.profile
Yep but I removed also from there
I found
in .xsession-errors. Maybe its related in some way?
Code: Select all
# if running bash
if [ -n "$BASH_VERSION" ]; then
# include .bashrc if it exists
if [ -f "$HOME/.bashrc" ]; then
. "$HOME/.bashrc"
fi
fi
# set PATH so it includes user's private bin if it exists
if [ -d "$HOME/bin" ] ; then
PATH="$HOME/bin:/bin"
fi
I found
Code: Select all
dbus-update-activation-environment: setting PATH=/usr/local/bin:/usr/bin:/bin:/usr/local/games:/usr/games
- Head_on_a_Stick
- Posts: 14114
- Joined: 2014-06-01 17:46
- Location: London, England
- Has thanked: 81 times
- Been thanked: 133 times
Re: Debian default $PATH where it comes from?
Debian seems to be setting PATH originally via the sysprofile package and a convoluted series of abstractions which I can't follow atm
Luckily for us this all irrelevant because if you have a specific PATH that you wish to set for any given user then simply override the default in ~/.profile, like this:
^ So that would remove /usr{,/local}/games from that user's PATH and add ~/bin
EDIT: your modification of ~/.profile did not work because in that stanza PATH is only set if ~/bin exists and I presume that it does not exist for your user.
My line would set PATH even if ~/bin does not exist (although it would be silly to add ${HOME}/bin to PATH in that case, obviously).
Luckily for us this all irrelevant because if you have a specific PATH that you wish to set for any given user then simply override the default in ~/.profile, like this:
Code: Select all
export PATH="${HOME}/bin:/usr/local/bin:/usr/bin:/bin"
EDIT: your modification of ~/.profile did not work because in that stanza PATH is only set if ~/bin exists and I presume that it does not exist for your user.
My line would set PATH even if ~/bin does not exist (although it would be silly to add ${HOME}/bin to PATH in that case, obviously).
deadbang
Re: Debian default $PATH where it comes from?
Alright I put export PATH to .profile, thanks for clarifying and your help
- Head_on_a_Stick
- Posts: 14114
- Joined: 2014-06-01 17:46
- Location: London, England
- Has thanked: 81 times
- Been thanked: 133 times
Re: Debian default $PATH where it comes from?
You're welcome
Please add [SOLVED] to the thread title to help others with this problem — it may also be best to change the title to "Debian: setting PATH for user" because I didn't actually find out how the default PATH is set.
Please add [SOLVED] to the thread title to help others with this problem — it may also be best to change the title to "Debian: setting PATH for user" because I didn't actually find out how the default PATH is set.
deadbang
Re: Debian default $PATH where it comes from?
this is wrong.pedegie wrote:.profileCode: Select all
# set PATH so it includes user's private bin if it exists if [ -d "$HOME/bin" ] ; then PATH="$HOME/bin:/bin" fi
where did you get that from?
it should be something like PATH="$HOME/bin:$PATH"
also look at /etc/profile.
- Head_on_a_Stick
- Posts: 14114
- Joined: 2014-06-01 17:46
- Location: London, England
- Has thanked: 81 times
- Been thanked: 133 times
Re: Debian default $PATH where it comes from?
That was the OP's attempted modification to that file.debiman wrote:this is wrong.pedegie wrote:.profileCode: Select all
# set PATH so it includes user's private bin if it exists if [ -d "$HOME/bin" ] ; then PATH="$HOME/bin:/bin" fi
where did you get that from?
It had no effect because ~/bin does not exist for that user
deadbang
- Head_on_a_Stick
- Posts: 14114
- Joined: 2014-06-01 17:46
- Location: London, England
- Has thanked: 81 times
- Been thanked: 133 times
Re: Debian default $PATH where it comes from?
Did you even bother to look in /etc/profile yourself before posting?debiman wrote:look at /etc/profile.
I ask because I did check and there is no mention of PATH in that file at all...
deadbang
Re: Debian default $PATH where it comes from?
Yep I have this there (which i also modified before posting):
Head_on_a_stick: How can I change topic's name? I want add that it's solved
Code: Select all
if [ "`id -u`" -eq 0 ]; then
PATH="/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin"
else
PATH="/usr/bin:/bin"
fi
export PATH
- Head_on_a_Stick
- Posts: 14114
- Joined: 2014-06-01 17:46
- Location: London, England
- Has thanked: 81 times
- Been thanked: 133 times
Re: Debian default $PATH where it comes from?
Edit the first post in this thread, that contains the "title" section for the thread and this is where you need to add [SOLVED].pedegie wrote:How can I change topic's name? I want add that it's solved
deadbang
Re: Debian default $PATH where it comes from?
i did, and there is.Head_on_a_Stick wrote:Did you even bother to look in /etc/profile yourself before posting?debiman wrote:look at /etc/profile.
I ask because I did check and there is no mention of PATH in that file at all...
on my debian system, it is the literal answer to the OP's title.
- Head_on_a_Stick
- Posts: 14114
- Joined: 2014-06-01 17:46
- Location: London, England
- Has thanked: 81 times
- Been thanked: 133 times
Re: Debian default $PATH where it comes from?
^ Really?
In which case, sorry about that, my mistake.
In which case, sorry about that, my mistake.
deadbang