TL,DR: Use su --login
or sudo
.
Debian sets a different PATH
for regular users. In /etc/profile
, you can see that the defaults reserve /sbin
for root:
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
type ifconfig
says the utility resides at /sbin/ifconfig
which is why regular users can't access it easily. When you run su
with no arguments, the calling user's environment is preserved, including the PATH
variable. sudo
, on the other hand, provides a fresh environment and overrides the calling user's PATH
.
The reason why you believe su
is malfunctioning is because resetting PATH
and IFS
by default is legacy behavior. buster recently switched to the util-linux
implementation of su
which works differently; see /usr/share/doc/util-linux/NEWS.Debian.gz
for details.