Debain(buster) su not working properly, command not found

  • For example: I installed ifconfig
  • First i become root with "su"
  • Now I write "ifconfig" and get: "command not found".
  • I write "sudo ifconfig" and now it works.

This seems to happen with a lot of programs (not all).

Another example: apt-get does not seem to properly install applications if I'm not using the same method.

I should not need to write sudo if I'm already root.

Why is that? What can I do to fix this?

3 Answers

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.

1

As dsstorefile1 said, the behaviour was changed.

Either you run "su -" instead of "su" or you could

add "ALWAYS_SET_PATH yes" to "/etc/login.defs" to preserve old Debians behavior.

use su - root instead of su root. Then type adduser username sudo

1

Your Answer

Sign up or log in

Sign up using Google Sign up using Facebook Sign up using Email and Password

Post as a guest

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

You Might Also Like