How to power off a Debian Linux box via console

19

4

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

Posted 2012-12-02T10:49:11.297

Reputation: 981

2I laughed at pleasejustwork. Thanks ;-) – gniourf_gniourf – 2012-12-02T11:00:52.513

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 – 2013-02-27T10:59:01.457

Answers

29

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:

gniourf_gniourf

Posted 2012-12-02T10:49:11.297

Reputation: 1 882

1This is no longer correct as of the Stretch release. – AlexLordThorsen – 2019-02-27T00:30:48.397

2Thank you. I will lookup sudo and root permissions. Why does it act like the command doesn't exist? – Luke Puplett – 2012-12-02T17:22:27.407

2@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 – 2012-12-02T17:24:38.687

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 – 2012-12-29T17:52:18.187

@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 – 2012-12-29T18:11:03.437

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 – 2012-12-29T18:18:18.980

0

You need to be root (or use sudo):

To shutdow the pc use:

$ systemctl poweroff

To restart the pc use:

$ systemctl reboot

Miloš Latinović

Posted 2012-12-02T10:49:11.297

Reputation: 1

0

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

haziz

Posted 2012-12-02T10:49:11.297

Reputation: 125

-2

As root you can use 'init 0' to shutdown and/or 'init 6' to reboot

Peter Duun

Posted 2012-12-02T10:49:11.297

Reputation: 1