howtouselinux

2 ways to shut down Linux system

Table of Contents

There are a couple of ways to shut down Linux. In this blog post, we will discuss two different methods: using the shutdown command and using the halt command. Let’s get started!

Shut down Linux with shutdown command in Linux

To shut down the Linux system, we can use shutdown command. Open the terminal and type the following command: shutdown -h now. This will immediately shut down the system without any warning. Note: Only the root user can shut down Linux system.

When using the shutdown command, there are a few different options that can be used. The most common option is -h, which stands for halt. This will immediately shut down the system without any warning. Another option is -r, which stands for reboot. This will reboot the system after it has been shut down.

The syntax of shutdown command in Linux is shutdown -h time “message”

  • -h : halt the system.
  • time : When to shutdown. You can poweroff immediately or after 2 minutes. It can be an absolute time in the format hh:mm, in which hh is the hour (1 or 2 digits) and mm is the minute of the hour (in wo digits). Second, it can be in the format +m, in which m is the number of minutes to wait. The word now is an alias for +0.
  • message: Send warning message to send to all users.

 

For example, to shutdown the system in 10 minutes with the following warning message: shutdown -h +10 “We need to shut down this server for maintenance. Please save your work ASAP.”

There are a few other options that can be used with the shutdown command. The -c option will cancel the shutdown.

Shut down Linux with halt command in Linux

The halt command is similar to the shutdown command, but it does not take any options. This command will also immediately shut down the system without any warning.

Advertisements

Both of these methods will shutdown Linux. Which one you use is up to you! If you need to quickly shutdown the system, then using the halt command is probably your best bet.

Update: As a few people have pointed out in the comments, there is actually a third way to shutdown Linux: using the poweroff command. This command is similar to the halt command in that it will immediately shut down the system without any warning.

What is the difference between the shutdown command and the halt command?

The main difference between the shutdown command and the halt command is that the shutdown command can take options, while the halt command does not. The most common option used with the shutdown command is -h, which stands for halt.

This will immediately shut down the system without any warning. Another option is -r, which stands for reboot. This will reboot the system after it has been shut down. The poweroff command is similar to the halt command in that it will immediately shut down the system without any warning.

What is the shutdown order in Linux?

  • Unmounts all file systems
  • Sends SIGTERM to all processes
  • Sends SIGKILL to all processes
  • Disables networking
  • Calls the kernel’s shutdown routines
  • Sets the system clock to 0 seconds since the epoch (Jan. 01, 1970)
  • Powers off the system (if possible)

 

How to change the shutdown order in Linux?

The order in which Linux shuts down can be changed by editing the /etc/init.d/halt file. To do this, open the file in a text editor and modify the lines that start with “stop()”. For example, to change the order so that networking is disabled before all processes are killed, you would change the line “stop() {“:

stop() {
# Disable networking
/etc/init.d/networking stop
# Send SIGTERM to all processes
killall -15

What happens if an application or service doesn’t respond to the shutdown request?

If an application or service doesn’t respond to the shutdown request, Linux will send that process a SIGTERM signal. This signal is intended to terminate the process immediately. If a process doesn’t respond to the SIGTERM signal, it’s likely because the process is in a locked state or is deadlocked. In these cases, the SIGKILL signal is usually the only way to terminate the process.

How to shut down Linux without going through all the steps?

If you want to quickly shutdown the system, then using the halt command is probably your best bet. However, if you want to give yourself a little bit of time to save your work, then using the shutdown command with the -h option is probably a better choice.

So there you have it, two different ways to shutdown Linux. Which method do you prefer? Let us know in the comments below! Thanks for reading!

Facebook
Twitter
LinkedIn

Loom is a video messaging tool that helps you get your message across through instantly shareable videos.

With Loom, you can record your camera, microphone, and desktop simultaneously. Your video is then instantly available to share through Loom’s patented technology.