* Robert Munteanu <rombert@apache.org> [11-01-19 11:26]:
On Fri, 2019-11-01 at 10:49 -0400, Patrick Shanahan wrote:
* Robert Munteanu <rombert@apache.org> [11-01-19 10:41]:
Hi,
On Fri, 2019-11-01 at 10:36 -0400, Patrick Shanahan wrote:
* Robert Munteanu <rombert@apache.org> [11-01-19 10:26]:
Hi,
I am having trouble understanding whether $HOME/bin should automatically be added to $PATH or if I should add it myself in $HOME/.bashrc. I recall this was working out of the box at some point but now it does not.
I looked in /etc/skel and /etc/profile.d but did not find any indication that it should be set.
Is $HOME/bin added by default to $PATH?
make a new <user> issue: echo $PATH
does /home/<user>/bin appear at the front of the output from "echo $PATH"?
Yes, it does. If I sudo as that user. In fact, the pattern is:
- open gnome-terminal/tilix/xterm - echo $PATH /usr/local/bin:/usr/local/sbin:/usr/bin:/usr/sbin:/bin:/sbin:/usr/X 11R6/bin
- sudo su - $USER ( or sudo su $USER ) - echo $PATH /home/robert/bin:/usr/local/bin:/usr/bin:/bin
Where is the difference coming from?
again: before you "sudo", try "echo $USER" if the output is robert, you are only sudo(ing) into your own and present account, not a new user or different user.
useradd <newuser> sudo <newuser> echo $PATH userdel <newuser>
does /home/<newuser>/bin appear at front of $PATH
Regarding your immediate question:
$ sudo useradd -m test $ sudo su - test $ echo $USER,$PATH test,/home/test/bin:/usr/local/bin:/usr/bin:/bin $ sudo userdel -r test
So for that user the path is correctly set. The same stands true for my own user as well, but only when using `sudo su -` or `sudo su` . Note that $USER is unchanged as points to the current user.
$ echo $USER,$PATH robert,/usr/local/bin:/usr/local/sbin:/usr/bin:/usr/sbin:/bin:/sbin:/us r/X11R6/bin $ sudo su - $USER $ echo $USER,$PATH robert,/home/robert/bin:/usr/local/bin:/usr/bin:/bin
So this is not about a new user vs existing ones, it's about how login is achieved. I get the path that does not include $HOME/bin by:
- logging in to tty1 - using xterm - using gnome-terminal - using tilix
So there's a clear difference how the paths are setup. Digging further, I see some path work being done in /etc/profile:
if test -z "$PROFILEREAD" ; then PATH=/usr/local/bin:/usr/bin:/bin if test "$HOME" != "/" ; then for dir in $HOME/bin/$CPU $HOME/bin ; do test -d $dir && PATH=$dir:$PATH done fi
(snip)
But not sure why it does not work in my case.
it is explained in "man sudo". if you (aiui): sudo $USER you do not inherit $USER's environment which includes $PATH. if you: sudo - $USER you do and $PATH should be the same and what $USER sees, ie: what $USER has in his environment. -- (paka)Patrick Shanahan Plainfield, Indiana, USA @ptilopteri http://en.opensuse.org openSUSE Community Member facebook/ptilopteri Photos: http://wahoo.no-ip.org/piwigo paka @ IRCnet freenode -- To unsubscribe, e-mail: opensuse-support+unsubscribe@opensuse.org To contact the owner, e-mail: opensuse-support+owner@opensuse.org