I am inside of an debian trixie lxc in proxmox.
This is how PATH looks when i query it from root:
# echo $PATH
/sbin:/bin:/usr/sbin:/usr/bin
In my /etc/login.defs my PATH configuration looks like this:
#
# *REQUIRED* The default PATH settings, for superuser and normal users.
#
# (they are minimal, add the rest in the shell startup files)
ENV_SUPATH PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin
ENV_PATH PATH=/usr/local/bin:/usr/bin:/bin:/usr/local/games:/usr/games
This is how my /etc/profile looks
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
To my understanding my root user PATH should include /usr/local/bin. What is the mechanism that is getting applied into my shell?
In my understanding according to INVOCATION in the bash man page there is a difference between interactive login shell and interactive shell. The interactive login shell loading /etc/profile, the interactive shell ~/.bashrc.
So i am assuming since my /etc/profile looks right, that i am in an interactive shell and not in an interactive login shell.
Is there a way how i can check the kind of shell i am in, or am i totally looking in the wrong place? What am i missing here?
Solution: Looks like exactly what i described:
root@pihole:~# echo $PATH
/sbin:/bin:/usr/sbin:/usr/bin
root@pihole:~# su -
root@pihole:~# echo $PATH
/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin
Forcing opening a login shell, makes the right PATH appear. Before that i am in an interactive shell but not in a login shell.
Note: I don't want to discuss, if it is a good idea to have /usr/local/bin in the root PATH. I want to know what is happening here.
echo "$0"?