24

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.

Luke Puplett
  • 1,561
  • 5
  • 18
  • 29
  • 9
    I laughed at pleasejustwork. Thanks `;-)` – gniourf_gniourf Dec 02 '12 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. – Shadur Feb 27 '13 at 10:59

5 Answers5

37

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:

Giacomo1968
  • 53,069
  • 19
  • 162
  • 212
gniourf_gniourf
  • 2,072
  • 18
  • 20
  • 2
    Thank you. I will lookup sudo and root permissions. Why does it act like the command doesn't exist? – Luke Puplett Dec 02 '12 at 17:22
  • 3
    @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`). – gniourf_gniourf Dec 02 '12 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`. – F. Hauri - Give Up GitHub Dec 29 '12 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`. – gniourf_gniourf Dec 29 '12 at 18:11
  • Of course you're right, but as question stand clearly for a *Debian Linux box*, this could be mentioned (maybe with remark about restricted solution). At all, the test `if runlevel == 6 || runlevel == 0` could become a standard in all Linux distrib in a near futur (if not already)... ( I guess ;-) – F. Hauri - Give Up GitHub Dec 29 '12 at 18:18
  • 1
    This is no longer correct as of the Stretch release. – AlexLordThorsen Feb 27 '19 at 00:30
  • As of newer systemd-based distributions, you'll need to first `sudo apt install systemd-sysv` to get the symlinks back, then follow the `su && reboot` or `sudo reboot` advice. – reukiodo Oct 24 '21 at 03:33
9

You need to be root (or use sudo):

To shutdow the pc use:

systemctl poweroff

To restart the pc use:

systemctl reboot
Giacomo1968
  • 53,069
  • 19
  • 162
  • 212
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!

ms geek
  • 21
  • 2
0

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

Fresh install may not have poweroff or shutdown as bash commands.

An alternative way to shutdown is:

systemctl poweroff

Must be root

login as root:

su root

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

0

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

haziz
  • 133
  • 1
  • 4