bash: shutdown: command not found
Solution 1
Binaries in the /sbin
and /usr/sbin
directories are intended to be run only be superusers/sudoers. If you want to run anything in there, prefix your command with sudo
. Your user will need to be a member of the sudoers
group though.
$ sudo shutdown -P +0
For proof of concept, try which shutdown
vs sudo which shutdown
.
Solution 2
Figured it out, you were on the right path with export PATH="$PATH:/usr/sbin"
. What you have to do is edit your .bashrc
file, and put export PATH="$PATH:/usr/sbin"
at the bottom, save, close. Then it'll work permanently.
Related videos on Youtube
theerrormagnet
Updated on September 18, 2022Comments
-
theerrormagnet over 1 year
I installed the latest version of Debian (netinstall).
I have the problem, that the terminal does not know commands likeshutdown
,reboot
, and so on.
When I dowhereis shutdown
it tells me it is in/usr/sbin
.
I fixed this on a different installation try by writing
/usr/sbin
into/etc/profile
where the$PATH
is written.
But this time it did not work.
I looked at this: https://wiki.debian.org/EnvironmentVariables, but either those files did not exist or I did not know where to put the path.
And doingexport PATH=$PATH:usr/sbin
is not permanent, it's gone after reboot, so that is garbage as well.
Edit: Wait, maybe I have to change the PATH in
/etc/environment
?!
I have to test this once I give Debian another try.-
ilkkachu about 3 yearsYou usually don't have the
sbin
directories in thePATH
for a regular user, since the stuff isn't that usable for a regular user. Though with Policykit or such,shutdown
could be. So I guess an important part here is if it's just the search path or not -- doesshutdown
work for you if you run it as/usr/bin/shutdown
? For the path, see e.g. How do I set a user environment variable? (permanently, not session) -
theerrormagnet about 3 yearsI can do
/usr/sbin/shutdown now
as root, but I want to use the commands without the whole path like in Ubuntu of course... -
Kusalananda about 3 yearsI notice that you use
usr/sbin
as the path, without the initial/
. You may want to make sure that your path contains/usr/sbin
rather thanusr/sbin
, and that/etc/profile
is correct too. Note also that you probably want to mention what shell you're using too, as some shells don't care about/etc/profile
(e.g.zsh
). -
FelixJN about 3 yearsNote that with the latest debian you might prefer the systemd-way in the first place:
systemctl poweroff
- you could alias this. -
psusi about 3 yearsYou will have to be more specific about what you did to /etc/profile to diagnose what you did wrong. Debian annoyingly defaults to only giving root sbin on the path, so I always remove the test for root from /etc/profile.
-
theerrormagnet about 3 yearsI did use the initial
/
beforeusr/sbin
. I have now switched back to Ubuntu, it has/usr/sbin
in its path by default. But I'm still clueless why it doesn't work in Debian.
-
-
theerrormagnet about 3 years
which shutdown
outputs nothing.sudo which shutdown
outputs:testuser is not in the sudoers file. This incident will be reported.
-
Ashley Miller about 3 yearsThat means your account isn't allowed to use
sudo
. If you're sure you want to, you can add the user to thesudo
group withusermod -aG sudo <username>
, but you'll have to do this on the root account (entersu
to switch to the root account), or at least another account that can runsudo
. -
AdminBee over 2 yearsWelcome to the site, and thank you for your contribution. Please note that your answer seems to reiterate what was already stated in the accepted answer, except for noting that you needed to install an additional package to implement it. As such, you should consider posting it as a comment below that answer (once you have sufficient reputation) or submit an edit suggestion.