5

What ways are there to shut down a computer using ssh? I'm running on linux and when I try to shut it down remotely using ssh, it doesn't actually work. I used the command sudo shutdown now. Afterwards, it said that the system is going down for maintenance NOW or whatever. However, when I got home, I came to discover that the computer was still on stuck on the Plymouth shut-down screen.

How can I achieve this?

  • 6
    Have you tried: su, enter password, shutdown -h now? – LPChip Apr 28 '15 at 22:14
  • 5
    This doesn't sound like a linux problem. This sounds like a hardware problem that your machine refuses to shut down after receiving the shutdown command. What is Plymouth? – hymie Apr 29 '15 at 0:28
  • 2
    What distribution and version of Linux are you using? What messages are showing on the Plymouth shutdown screen? Can you edit your question to post a screenshot? Have you looked at the log files (e.g., /var/log/messages)? Can you edit your question to include the relevant part of the log file from when you began the shutdown to when it got stuck? If you want a good diagnosis you should provide more information. – D.W. Apr 29 '15 at 1:32
17

Multiple ways, depending on habits and needs, but the most common method is:

shutdown -h now

Because it’s clean, it does a sync for all drives, and it’s easy to alter its behavior if you for some reason want to., For example, shut down an hour in the future instead.

In your particular case, it’s missing the -h flag, which requests a poweroff as well. Without the -h flag, it is left on the linux equivalent of the old Windows 95 “You can now shut off your computer” or whatever it was that it used to say.

  • 1
    This might depend on the platform. At least on Fedora 21 (with systemd), --poweroff is the default, so shutdown now will shut down the machine even without the -h flag. I haven't checked any other distribution or version of Fedora. Have you checked what distros this applies to? – D.W. Apr 29 '15 at 1:34
  • @D.W. Most of the ones I use (centos, mint, arch), but I do remember FreeBSD 4.0 (yep, that long ago) being different, although I cannot remember how. – Jarmund Apr 29 '15 at 7:30
  • 1
    This is the right solution! I have a Debian VM that I connect to, using xmin, and this is the command I use to shut it down. And it works all the time. – Ismael Miguel Apr 29 '15 at 8:31
  • 1
    I usually use exec shutdown -h now just so the bash shell I am running it from gets to save its history before the shutdown command is run. – kasperd Apr 29 '15 at 17:18
  • For how the BSDs are different, including from one another, see unix.stackexchange.com/a/196471/5132 . For how the semantics of shutdown now have changed with systemd, see unix.stackexchange.com/a/196014/5132 . – JdeBP May 1 '15 at 21:52
9

Try sudo shutdown -h now (the -h is for "halt")

Otherwise, see if something is hanging it up. Modem Manager and Network Manager are known to cause issues on some distros.

7

Instead of shutdown try the poweroff command. This may not work on all distros though.

5

Taken from: Shutting down a computer remotely

Shutdown doesn't turn off the computer unless you use the -P option e.g.

sudo shutdown -P now

Alternatively you can use sudo poweroff which does the same thing.

  • 1
    This might depend on the platform. At least on Fedora 21 (with systemd), --poweroff is the default, so shutdown now will shut down the machine even without the -h flag. I haven't checked any other distribution or version of Fedora. Have you checked whether that answer is still valid on modern Linux distros? – D.W. Apr 29 '15 at 1:34
  • --poweroff is for unpriveldged useres I did assume (maybe prematurely) that it was a elevated ssh session (I also use Fedora --22 in my case) – linuxdev2013 Apr 29 '15 at 17:43
2

You have diferent ways:

By Run Level

init 0

with Shutdown command

shutdown [-option] time

example:

shutdown -h now

Another ways:

Poweroff <--- Reference

poweroff

Halt <--- Reference

halt
1

I normally use the init command to do that. If you want to shutdown it's this:

sudo init 0

Nobody has suggested this so far. Is there a disadvantage or reason not to use runlevels?

  • 2
    Well the systemd doco does say that "the concept of SysV runlevels is obsolete". ☺ The actual thing that people haven't addressed so far is not the commands to use, but why a shutdown would have got stuck on a plymouth screen. But the questioner hasn't even told us the operating system being used. – JdeBP May 1 '15 at 22:15

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.