[Freedombox-discuss] rebooting system from ssh

Znoteer znoteer at mailbox.org
Sat Jan 4 15:37:27 GMT 2020


Hi,

On Sat, Jan 04, 2020 at 06:15:41AM +0000, Nicholas Greensmith via Freedombox-discuss wrote:
> Thanks guys!
> 
> Out of curiosity though what's the reason behind command not found when
> called without sudo?  I would have expected 'permission denied'.

It's because of the PATH environment variable.  $PATH is different for
ordinary users with regard to the root user.  When you type a command name
without its full path, the system uses $PATH to find the command.  The full
path for the shutdown command is "/sbin/shutdown".  reboot is also in the
/sbin directory.  

Try "echo $PATH" as both root and as an ordinary user:

$ echo $PATH
/usr/local/bin:/usr/bin:/bin:/usr/local/games:/usr/games

The ordinary user's PATH contains the following directories
/usr/local/bin
/usr/bin
/bin
/usr/local/games and
/usr/games

There's no /sbin in the list.  That's why you get command not found.  The
system can't find it because the system wasn't told to look in /sbin.

Here's root's PATH value:

$ sudo su -
root at fbx:~# echo $PATH
/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin

The second to last entry is /sbin, so the system know to look in that
directory when looking for the command.

I hope this was clear,

-- 
Znoteer
znoteer at mailbox.org



More information about the Freedombox-discuss mailing list