How to Use Linux Shutdown Commands

How to Use Linux Shutdown Commands

Title: How to Use Linux Shutdown Commands
For You. Get More Information from our site @iwanrj.com free.

Most well-known operating systems have different ways to turn off a computer or laptop. Likewise with Linux, this operating system has various ways to safely shutdown, reboot, hibernate, or even suspend Unix-based devices. In this tutorial, we will discuss how to use the Linux shutdown command and how to reboot and hibernate a VPS.

For this tutorial, we are using two different versions of Linux – CentOS 7 and Ubuntu 18.04.

Shutting down and rebooting the server is an important action that every operating system needs to take to maintain the stability of your device. Shut down or turn off the server using a specific command line is a safe way to notify logged in users that the system will be disabled.

In this tutorial you will also learn how to make Linux shutdown automatically.

Ubuntu and CentOS Shutdown commands

The Ubuntu and CentOS ‘shutdown’ command functions to shut down, reboot, and stop the device system. Below is the command syntax for shutdown and restart.

 Shutdown [OPTIONS] [TIME] [WALL]

The first argument of [OPTIONS] is a time string. After selecting this argument, then you can type a wall message to warn logged in users that the system will be shut down.

The format for the time string is hh:mm (hours/minutes), while the time format itself uses the 24-hour rule. The function of this string is to indicate the time when the shutdown command will be executed. You can also use elements +m indicating minutes. This instruction will instruct the device to turn off automatically in the desired number of minutes.

To turn off the VPS right away, you can use the syntax now which is an alias for +0. If you don’t specify arguments [time]then Linux will set it to +1 by default before shutdown is performed.

Note that you must specify a time argument if you want to create a wall message. Files /run/non-login will be created 5 minutes before the system is disabled provided you have specified a time argument to warn the user who wants to login.

Using Linux Ubuntu and CentOS Shutdown Commands

The shutdown command for Ubuntu and CentOS is relatively the same. Each of the commands shown below can be used in a dedicated Terminal. Keep in mind, you must use SSH to log in to the VPS server. We have a tutorial that covers the process using PuTTY!

Here are the basic shutdown commands for both CentOS and Ubuntu:

shutdown

Using the command above, it will take the PC about one minute to shut down. Please save all your work before executing the shutdown command.

If you want to turn off the PC right away, type this command at the command line, then press enter :

 shutdown now

As previously pointed out, both Ubuntu and CentOs commands are the same.

To shutdown the computer at your desired time, type the command below on the command line, then press enter :

 shutdown hh:mm

The Linux shutdown command follows a 24 hour format. So, type in the hour you want it on hh and minutes on mm. For example, shutdown 13:50.

To shut down Linux after a few minutes or hours, type the command below, then press enter :

 shutdown +m

Note that the m in the command represents minutes. So, you just specify the number of minutes.

To display a message to users who are logged in to your VPS, type the following command and press enter :

 Shutdown +m “Please save your Work, the PC will Shutdown in 5 Minutes”

You can write any text in this command.

Restart Your VPS With Linux Shutdown Commands

So that the computer can be safely restarted or rebooted, use the command below:

 shutdown –r

By running the Linux shutdown command above, your device will take about a minute to reboot. Save all your work before the reboot process is activated.

To restart your computer right away, simply add the now option, as was done before.

 shutdown –r now

To schedule a restart, type the following command and press enter :

 shutdown –r hh:mm

To restart the device after a certain number of minutes or hours, type the following command. After that, press enter :

 shutdown –r +m

You need to remember, here m shows minutes. So you just need to specify the desired number of minutes.

To display a message to users who log into your server before the system shuts down, type the following command, then press enter :

 Shutdown –r +m “Please save your Work, the PC will restart in 5 Minutes”

Here are some command options to shutdown Linux:

  • -poweroff, -P: to force shutdown the system (and thus the unit).
  • -reboot, -r: to reboot the system
  • -halt, -h: to force stop the device after its process is complete

Below is the command to shut down the device using the halt option:

 shutdown –h

As for the power off options are:

 shutdown –p

In the above command, you can also specify the time, then generate the message after setting the option argument.

Canceling a Scheduled Shutdown Command in Linux

To cancel the scheduled shutdown or restart of the computer, you only need to type the following command before the specified time.

 shutdown –c

The command above will immediately cancel the scheduled shutdown or restart time. If you choose +0 or nowthen the shutdown command cannot be applied.

Be the first to rate it

Avatar of Iwan N
I'm A Web Developer