Seems every couple months I have to look this up again, so I'm just going to drop it here. If you're having trouble running privileged commands after su in buster, well... they changed it. For the better, I'm sure, but changed all the same.
The su command in buster is provided by the util-linux source package, instead of the shadow source package, and no longer alters the PATH variable by default. This means that after doing su, your PATH may not contain directories like /sbin, and many system administration commands will fail.
There are several workarounds:
- Use
su -instead; this launches a login shell, which forcesPATHto be changed, but also changes everything else including the working directory. - Use
sudoinstead.sudostill runs commands with an alteredPATHvariable. - To get a regular root shell with the correct
PATH, you may usesudo -s. - To get a login shell as root (equivalent to
su -), you may usesudo -i. - Put
ALWAYS_SET_PATH yesin/etc/default/su(create it) to get an approximation of the old behavior. This is documented in su(1).
echo "ALWAYS_SET_PATH yes" >> /etc/default/suSee: Changes