I have just installed a brand new debian buster:
$ lsb_release -a
No LSB modules are available.
Distributor ID: Debian
Description: Debian GNU/Linux 10 (buster)
Release: 10
Codename: buster
$ cat /etc/profile
[..]
if [ "`id -u`" -eq 0 ]; then
PATH="/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin"
else
PATH="/usr/local/bin:/usr/bin:/bin:/usr/local/games:/usr/games"
fi
export PATH
[...]
$ whoami
zozo
$ su
Password:
# id -u
0
# printenv | grep -i ^path
PATH=/usr/local/bin:/usr/bin:/bin:/usr/local/games:/usr/games
If I run as root:
# grep -i path /etc/profile.d/*no output# grep -i path ~/.profileno output# grep -i path ~/.bashrcno output
Being on a Debian system there is no ~/.bash_profile nor ~/.bash_login
vi ~/.profile
PATH="/usr/bin:/bin:/usr/sbin:/sbin"
but the problem remains:
Ctrl+D to get back to normal user
then
$ su
password:
printenv | grep -i ^path
PATH=/usr/local/bin:/usr/bin:/bin:/usr/local/games:/usr/games
So I made some searches: 6.2 Bash Startup Files
then
if [ -z "$PS1" ];then echo NOT interactive shell ;else echo INteractive shell ;fi
INteractive shell
it says:
When Bash is invoked as an interactive login shell, [...] it first reads and executes [...] /etc/profile [...]. After [...] it looks for [...] ~/.profile ...
So I am wondering why it does not load PATH from ~/.profile (~/.profile is not called/loaded). Of course, if I put it in ~/.bashrc, it works.
So, at the end, by default, no path for essential commands like shutdown or reboot.
Furthermore, I am realizing that tools like systemctl, which are by essence an administration commands are located in /usr/bin instead of /sbin or /usr/sbin (and many other admin commands, like getfacl, setfacl... but that's another problem).
I should have missed something here.
echo $0print? – schily Jun 24 '20 at 10:40~/.profile). Usually, the display manager takes care of setting up the environment for each graphical user session. E.g. I see on a fresh buster VM that gdm3 (GNOME display manager) runs a login shell (and thus sources~/.profile) toexecthe GNOME Session Manager. Changes to~/.profilerequire you to log out/in to be visible, but should also take effect immediately in a login shell (i.e. invoked asbash -l). (Cont...) – fra-san Jun 24 '20 at 22:08