How to Reboot or Shut Down Linux Using the Command Line

Share
  • April 26, 2019

Feel like starting over? This tutorial will show you how to cleanly and safely reboot or shut down your Linux or macOS computer from the command line.

We’re Going Down

Sometimes you just have to go for the reboot or the total shutdown. If you’re working on a GUI-less server or you’re on an SSH session to a remote computer, the command line is your only option. Linux and Unix-like systems such as macOS provide several commands to shutdown or reboot your system right from the command line.

The commands you can use are:

  • shutdown
  • reboot
  • halt
  • poweroff

Looking through the man pages for these commands can be confusing. Depending on which command line options you choose, all of these commands can perform shutdowns, reboots, and system halts. In fact, the man pages for reboot, halt, and poweroff contain exactly the same information.

man page for halt command

What’s Behind This?

The answer lies in the systemd bootstrap system which replaced the venerable System V init system. In the Linux world, Fedora started to use systemd in 2011. Since then it has been adopted by a great many distributions. Debian and Ubuntu swapped to systemd in 2015.

On systemd-based distributions the shutdown, reboothalt, and poweroff commands are effectively shortcuts that point to the systemctl command. Retaining these commands provides a degree of compatibility with System V init-based distributions. It means shell scripts (and hard-core System V system administrators) don’t keel over if they are moved to a computer with a systemd distribution running on it.

Using Shutdown

Shutting down or rebooting a multi-user system means you have to plan ahead. You need to decide when you’re going to go for the shutdown or reboot, and warn the other system users the shutdown is coming, and when. If it is your own computer and you’re the only one who uses it, life is much simpler.

Read the remaining 29 paragraphs

Source : How to Reboot or Shut Down Linux Using the Command Line