2

What is the proper sudo terminal command to shutdown the computer gradually, saving everything, closing everything in the right order, and basically doing everything the computer needs to be doing to shutdown properly without any damage, in a safe manner just like you would shut down by clicking on the shutdown menu button with your mouse? I am asking for a command that shuts it down without any further actions, so the suggested gnome-session-quit --power-off is not a fit here.

And please give me one command, not a bunch of variants. Or if you do give me multiple options, please explain in which way they are different from each other.

3
  • "Saving everything"? There exists no such command. At least that part would require manual intervention, whether you do it with the mouse or not.
    – muru
    Jan 31, 2015 at 0:09
  • If you want the same as clicking shutdown from the menu, then $ sudo shutdown -h now will do it. If you do $ man shutdown you can read right on the first line that "shutdown arranges for the system to be brought down in a safe way".
    – Daniel
    Jan 31, 2015 at 0:13
  • @karavar: Check this.. askubuntu.com/a/578155/216503
    – heemayl
    Jan 31, 2015 at 18:05

3 Answers 3

1

Clicking on the shutdown button with your mouse is equivalent to calling gnome-session-quit:

gnome-session-quit --power-off
4
  • what about "sudo shutdown -P now"? what would be the difference?
    – Zeno
    Jan 31, 2015 at 0:20
  • 1
    @Karavar In effect, I don't know. In usage, this doesn't need sudo.
    – muru
    Jan 31, 2015 at 0:24
  • the command u gave me doesn't shutdown my computer. it just prompts me to a menu with multiple options like: logout,suspend, restart and shutdown. i am asking for a command that shuts it down without any further actions. thank you!
    – Zeno
    Jan 31, 2015 at 0:37
  • @Karavar then why is that in a comment and not in the question?
    – muru
    Jan 31, 2015 at 0:42
1

I always used this

sudo shutdown -h now 

This

arranges for the system to be brought down in a safe way

For more information, refer to man 8 shutdown

Note that above, now is the current time and can replaced by -t sec 30, which means 30 seconds later. While the command is also working without, it is considered best practice to use -h (thanks Daniel and Bay Dam).

0
0

Another option that worked for me is sudo systemctl reboot. This is also usable on all other distros using SystemD, such as e.g. OpenSUSE.

Works on any Ubuntu from 15.04, reference

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.