26

Brand new to Linux. I need to turn my box off and put it in my server room. The help here and everywhere seems not to work for me:

http://debianhelp.co.uk/shutdown.htm

I get:

lukepuplett@uktnlx01:~$ poweroff
-bash: poweroff: command not found
lukepuplett@uktnlx01:~$ shutdown
-bash: shutdown: command not found
lukepuplett@uktnlx01:~$ modprobe apm
-bash: modprobe: command not found
lukepuplett@uktnlx01:~$

I also tried halt, reboot, goaway, and pleasejustwork.

2
  • 9
    I laughed at pleasejustwork. Thanks ;-) Dec 2, 2012 at 11:00
  • The shutdown command is not accessible to a non-superuser by default as it's in /sbin/ rather than in /bin/ or /usr/bin/. The former is not normally added to the $PATH of a regular user. Feb 27, 2013 at 10:59

5 Answers 5

40

You need to be root (or use sudo):

# This halts (shuts down) the computer now
sudo shutdown -h now

# This reboots the computer now
sudo shutdown -r now

Read the manual page for shutdown: man shutdown for more information.

In the link you gave, you just overlooked the sentence

simply run as root:

7
  • 2
    Thank you. I will lookup sudo and root permissions. Why does it act like the command doesn't exist? Dec 2, 2012 at 17:22
  • 4
    @LukePuplett The shutdown command is in the /sbin directory, which is not in your path. It is hence not found by bash when you're calling it while not being root. Compare which shutdown (no output) with sudo which shutdown (output is sbin/shutdown). Dec 2, 2012 at 17:24
  • Command halt or reboot could be prefered, (at least from version 6 of Debian). As If halt or reboot is called when the system is not in runlevel 0 or 6, in other words when it's running normally, shutdown will be invoked instead (with the -h or -r flag). see man halt. Dec 29, 2012 at 17:52
  • 1
    @F.Hauri In most distributions, halt and reboot are low-level commands, and shutdown is the high-level one. I prefer using the high level one, that takes time to run clean-up scripts, etc... in some distributions (e.g., Debian), but not all, halt and reboot do call shutdown... so what's the point? Anyway, my preference is really for shutdown. Dec 29, 2012 at 18:11
  • 1
    This is no longer correct as of the Stretch release. Feb 27, 2019 at 0:30
12

You need to be root (or use sudo):

To shutdow the pc use:

systemctl poweroff

To restart the pc use:

systemctl reboot
1
  • this only works when systemd is being used
    – phuclv
    Mar 7, 2023 at 9:17
2

debian-11.6.0-amd64-netinst minimal with non free firmwares

Fresh installs may not have poweroff or shutdown available to basic users as bash commands.

An alternative way to shutdown is:

systemctl poweroff

My method: Must be root

Login as root:

su root

or my fav

su -

then

reboot

Should work as normal.

This link could help others: https://wiki.debian.org/shutdown

2
  • Is this adding anything more to the previous answers Mar 7, 2023 at 4:57
  • This answer adds an important point - with just a base install, the poweroff and shutdown commands are not available. Running systemctl poweroff is the only option.
    – ghd
    Oct 21, 2023 at 16:08
1

Had the same issue, and in my (Debian 7) installation

sudo poweroff

or

sudo shutdown

did not work. All I got was command not found. Only after becoming root I could issue the commands. To become root:

su

then poweroff and shutdown works!

0

halt, run as root, or sudo halt if you are on the sudoers list, should do the trick.

2
  • how to be inside sudoers list?
    – gumuruh
    Oct 29, 2020 at 15:03
  • 1
    @gumuruh man sudoers, man visudo
    – Annahri
    Nov 15, 2020 at 2:07

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .