Categories
Linux Tutorial Series

Linux Tutorial Series – 158 – Shutting down your system via the command line

Here is the video version, if you prefer it:

If you ever want to shut your system down via the command line, here is how it is done: (Ward, 2014)⁠

shutdown -h now

If you want to restart your machine, execute this:

shutdown -r now

In order to delay the shutdown or the restart, write this (this is the shutdown case):

shutdown -h +numberofMinutes

I usually shut down my computer via the GUI, but there may be some situations where you might have to shut down the computer via the command line (such as when accessing a computer remotely, for example).

Hope you learned something new!

References

Ward, B. (2014). How Linux Works: What Every Superuser Should Know (2nd ed.). No Starch Press. Pages 144-145

Categories
Linux Tutorial Series

Linux Tutorial Series – 157 – Shutting down your system – what goes on

Here is the video version, if you prefer it:

When you want to shut down your system, the following happens: (Ward, 2014)⁠

  1. init asks every process to shut down
  2. If some processes (or a process) don’t respond, init initiates a kill with a TERM signal
  3. If some processes (or a process) don’t respond still, init initiates a kill with a KILL signal
  4. The system makes preparations for a shutdown
  5. The system unmounts all of the other filesystems other than root
  6. The system remounts the root filesystem in read-only mode (meaning you can’t write, only read)
  7. The system writes out all of the data left over in the buffers to the filesystem (this happens during the remounting process; see (“Is the root filesystem unmounted during a Linux shutdown?,” n.d.)⁠)
  8. The kernel reboots or stops the system

My 2 cents – just know this conceptually. The only case where you will need to go deep into the details of this will be if you need to optimize something on a Linux machine (most likely you would be doing this professionally), if you need to know the details to accomplish some other task or if you are really really curious.

Hope you learned something useful!

References

Is the root filesystem unmounted during a Linux shutdown? (n.d.). Retrieved February 13, 2020, from https://unix.stackexchange.com/questions/298216/is-the-root-filesystem-unmounted-during-a-linux-shutdown

Ward, B. (2014). How Linux Works: What Every Superuser Should Know (2nd ed.). No Starch Press. Pages 144-145