How to shut down your Linux system

8

Linux comes with different utilities that allow the device to be rebooted, stopped, or turned off by a system administrator. To run commands, one must be a root or group member.

The “shutdown” is employed to shut down and restart our system while the Reboot command restarts the system only. The “halt” command stops all hardware functions. It terminates the running processes and shutdown the CPU without shutting down the system.

This post illustrates how to use a terminal to shut down, restart and halt your systems.

Syntax:

The fundamental syntax of “shutdown” command is given below:

$ sudo shutdown [option] [ time]

Follow the below syntax to broadcast message before shutdown.

$ sudo shutdown [option] [ time] [ message]

Using shutdown command:

Open your terminal and type “shutdown” without any argument. The below-given command will shut down your system after 1 minute:

Use the shutdown with the “sudo” command to give the administrative privileges. Run the shown below command:

Shutting down immediately:

Run the command to shut down the computer immediately:

When you enter your password, the system will shut down immediately.

Alternatively, we can use “now” instead of 0:

Use the power off parameter with shutdown command as shown below:

$ sudo shutdown –poweroff now

Defining time to shut down the system:

You can also define a time in hours and minutes for your machine to shut down as follows.

Use the following command to shut down your machine in 5 minutes:

Let’s assume you want to shut down your system at 7 PM; run the below-mentioned command:

Broadcasting the message:

If multiple users are using the system, the notification will pop up on all users screens to tell them exactly that a shutdown is going to happen:

$ sudo shutdown 15 “save your work, Your system will shut down in 5 minutes.”

Cancellation of the shutdown process:

You can cancel the scheduled shutdown process by executing the below-mentioned command:

How to use the “reboot” command in Linux:

Reboot command restarts your system after it gets shut down.

Use the command showing below to reboot your system:

Or

0r

Defining time to reboot the system:

Define time unit in hours, minutes, and seconds. The shutdown -r command will reboot the system after 10 minutes:

It shows the system will restart after 10 minutes.

Displaying Alert message:

Like shutdown, if multiple users are running the system, a warning message will appear on each user’s screen to inform them that something is about to happen.

$ sudo shutdown –r 10 “Your system will restart after 10 minutes.”

How to use “halt” with the “shutdown” command in Linux:

The “halt” option with the “shutdown” command shuts down the operating system but does not power the machine off. It will stop the CPU functioning:

Use the one command:

How to create keyboard shortcuts to shut down:

You can also shut down, reboot, and halt your system by using shortcut keys. These keys can be created in Ubuntu.

Open “Settings”, navigate to “Keyboard Shortcuts,” and on the bottom of the screen, click on the “+” symbol to create a new short cut:

A new window will open:

Assign a name and enter the command. For instance, if you want to create a shortcut key to power off the system, use the command given below:

gnome-session-quit–power-off–force

Click on the “Add” button.

To enable the short cut key, click on the “Disable” button and assign a shortcut by holding the keys of your choice:

Once you press the keys, the following window will appear displaying your pressed buttons:

Similarly, to reboot and halt, follow the same process described above and use the following commands:

For reboot:

gnome-session-quit–reboot–force

For halt:

gnome-session-quit-halt–force

New shortcuts have been created. Now, let’s test the assigned shortcut keys. To reboot the system, press CTRL+ SHIFT+R, a message will appear asking to “Restart” your system, as displayed in the image below:

Conclusion:

“Shutdown” is a command-line utility used to turn off or restart your system. It is a very good habit to shut down your system regularly. When you shut down your system, all the files and processes get closed. With the “shutdown” command, you can also set time and alert messages. Reboot and halt command is also used with the shutdown. Restarting your system is a good approach to clears the RAM and eliminates memory bugs. This post demonstrated how to shut down, reboot, and halt your Linux system using the command line or keyboard shortcuts.

This website uses cookies to improve your experience. We'll assume you're ok with this, but you can opt-out if you wish. Accept Read More