21

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.

  • 5
    I laughed at pleasejustwork. Thanks ;-) – gniourf_gniourf Dec 2 '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
32

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:

  • 2
    Thank you. I will lookup sudo and root permissions. Why does it act like the command doesn't exist? – Luke Puplett Dec 2 '12 at 17:22
  • 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 Dec 2 '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 Dec 29 '12 at 17:52
  • @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
  • 1
    This is no longer correct as of the Stretch release. – AlexLordThorsen Feb 27 '19 at 0:30
4

You need to be root (or use sudo):

To shutdow the pc use:

systemctl poweroff

To restart the pc use:

systemctl reboot
1

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

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

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!

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.