bash: shutdown: command not found

15,156

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.

Share:
15,156

Related videos on Youtube

theerrormagnet
Author by

theerrormagnet

Updated on September 18, 2022

Comments

  • theerrormagnet
    theerrormagnet over 1 year

    I installed the latest version of Debian (netinstall).
    I have the problem, that the terminal does not know commands like shutdown, reboot, and so on.
    When I do whereis 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 doing export 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
      ilkkachu about 3 years
      You usually don't have the sbin directories in the PATH 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 -- does shutdown 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
      theerrormagnet about 3 years
      I 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
      Kusalananda about 3 years
      I 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 than usr/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
      FelixJN about 3 years
      Note that with the latest debian you might prefer the systemd-way in the first place: systemctl poweroff - you could alias this.
    • psusi
      psusi about 3 years
      You 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
      theerrormagnet about 3 years
      I did use the initial /before usr/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
    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
    Ashley Miller about 3 years
    That means your account isn't allowed to use sudo. If you're sure you want to, you can add the user to the sudo group with usermod -aG sudo <username>, but you'll have to do this on the root account (enter su to switch to the root account), or at least another account that can run sudo.
  • AdminBee
    AdminBee over 2 years
    Welcome 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.