Ubuntu

Ubuntu Shutdown Command Explained

As time passed, Linux gradually added a GUI to its OS, although Ubuntu was initially a terminal-based platform. These days, a number of operating system problems can only be fixed with GUI methods. One of those issues is to shut down your Linux machine. Like other OS, Ubuntu provides several options to securely restart, hibernate, or stop a Unix-based workstation. These include the simple methods such as using a terminal to send the commands to the computer or clicking a button. We’ll walk you through some incredible methods to safely turn off your Ubuntu machine!

Ubuntu Shutdown via GUI

The very first and conventional way to shut down your Ubuntu system is to use the “Power Off” option available in the “Settings” panel of your system. Expand the “Power Off tappedog Out” option from the displayed drop-down list and tap on the “Power Off” option.

Tap on the “Power Off” button from the appeared dialogue window to shut your Ubuntu system.

Ubuntu Shutdown Command via the Terminal

Let’s move towards using the “shutdown” command in the Ubuntu system. For this, we use the Ubuntu command-line utility named “Terminal” in the illustrations. To open the “Terminal” of the Ubuntu system, use the “Ctrl+Alt+T” shortcut or open it via the activity menu that is held at the top-left corner of the Ubuntu screen. The command-line utility will be launched with your current username. Now, we simply execute the “shutdown” command to power off our machine. But using it without any “Sudo” privilege throws an error and doesn’t shut down the Linux machine.

$ shutdown

When you try to use the shutdown instruction with the “Sudo” rights without passing any options, it will immediately power off your machine without a blink. After a successful power-off via the command, you must restart your machine from the Virtual Box if required.

$ sudo shutdown

Option “Now”

In the previous illustration, we used the “shutdown” instruction with no options. You can get the same effects of the “shutdown” instruction using the “now” option, i.e., immediate power off of the machine after executing the instruction.

$ sudo shutdown now

Option “-P”

The use of the “shutdown” instruction with the “-P” option also gives the same effects that you can get from the “shutdown” instruction alone or with the “now” option. The “-P” option explicitly specifies that this is to perform the “power off” operation.

$ sudo shutdown -P

Option “-r”

Sometimes, it becomes the system requirement to shut down the system and reboot it once again to make sure that the system gets the effects of the new installations and the repositories can be updated. To perform the reboot process of a system right after the shutdown, you can use the “-r” option within the “shutdown” instruction. With this instruction, you will witness the system reboot after a shutdown of the Ubuntu system.

$ sudo shutdown -r

The “now” option can be utilized with the “-r” option within the “Shutdown” instruction to shut down and reboot an operating system immediately.

$ sudo shutdown -r now

Option “-h”

In case you are unaware, stopping/halting a system is different from turning it off. Although the shutdown option ensures that the main power is cut off, the “halt” option entails halting all CPUs without the power cut off. Using the “-h” option in the shutdown command may make you wait 1 minute to shut down the system services.

$ sudo shutdown -h

To immediately halt the Ubuntu system, you can make use of the “now” option along with the “-h” option in the “shutdown” instruction as follows:

$ sudo shutdown -h now

Schedule the Shutdown via the Terminal

All the previous illustrations of “shutdown” commands with different options depict the immediate shutdown or halting of an Ubuntu system. Sometimes, the users might want to shut down or halt a system after a specific time or at any hour of the day. The “shutdown” instruction can be used for scheduled shutdown or reboot in the Ubuntu system using the time option in the command. We can specify the time for a shutdown in different ways. For instance, to schedule a shutdown after 40 minutes from now, you have to use the “+” sign followed by the number “40”. The execution of this “shutdown” instruction successfully schedules the shutdown of a system after 40 minutes.

$ sudo shutdown +m

In case you want to display a message for a user to save the work just before the system shutdown, you can do so by specifying the message after a specified time in the “shutdown” command as displayed in the command beneath. This way, we remind a user that there is a scheduled shutdown that can shut down all activities.

$ sudo shutdown +m “Text message…”

Within the previous illustration, we specified the time in the “shutdown” instruction according to the current time, i.e. shutdown after 40 minutes from now, etc. You can also schedule a shutdown at any specific time using the “hour: minutes” method. In this method, you specify any “hour” of a day and its exact “minutes” to schedule a shutdown. For instance, we mention “15:30” in the “shutdown” instruction to schedule a shutdown at 03:15 PM on a current day. Now that the shutdown has been successfully planned, it may be seen in the instruction’s output.

$ sudo shutdown h:m

In case you want to schedule a shutdown at a specific time of the day and also wants to reboot the system at the same specified time, you can use the “-r” option in the “shutdown” instruction as follows:

$ sudo shutdown -r h:m

You can also schedule a system halt using the “-h” option followed by the specified time. The following command schedules an immediate halt using the “+0” minutes:

$ sudo shutdown -h +m

Sometimes, you might find that there is no need for a scheduled shutdown. Thus, you want to cancel all the scheduled shutdowns. For this, you have to use the same “shutdown” instruction with the “-c” option as follows:

$ sudo shutdown -c

Conclusion

This guide elaborates on utilizing the “Shutdown” command in the Ubuntu system. We utilized a variety of available options for the “shutdown” command to shut down immediately or after a few minutes. The “shutdown” instruction is also elaborated for the scheduled shutdown, halt or reboot. We also displayed the method of Ubuntu shutdown using the GUI utility.

About the author

Omar Farooq

Hello Readers, I am Omar and I have been writing technical articles from last decade. You can check out my writing pieces.