Your user's PATH
environment variable does not contain the path where these files are located. When you use su -
, root's environment variables get loaded into your session. See man su
:
-, -l, --login
Start the shell as a login shell with an environment similar
to a real login:
o clears all the environment variables except TERM and
variables specified by --whitelist-environment
o initializes the environment variables HOME, SHELL,
USER, LOGNAME, and PATH
o changes to the target user's home directory
o sets argv[0] of the shell to '-' in order to make
the shell a login shell
To better understand this, let's look at where one of these binaries is, and compare root's PATH with yours:
- do
su -
- do
which service
. This will tell you where the service
binary would be loaded from if you were to run the command service
.
- do
echo $PATH
. This will show you root's PATH. You will note that the directory where service
can be found is listed here.
- do
exit
to become your non-root user again.
- do
echo $PATH
. You'll see that the directory you identified in step 2 is not here.
This is a normal default setup in certain environments/distros where certain administrative programs like service
, fdisk
, etc. are kept in a directory such as /usr/sbin
or /sbin
, with such directories kept off of normal users' PATHs.
I have not changed any PATH before, so why should i have to edit it now? Is there something new to Debian 10?
I don't use Sudo.. and it doesn't work with "su root" so why should it work with "su -"
– Johnny Doe Nov 22 '19 at 14:56but thats not an explanation why it is like it is.
– Johnny Doe Nov 22 '19 at 15:06