In this article, we explore different ways to control your Linux system’s power state. Our main focus is on the versatile linux command to shutdown, but we’ll also cover restarting, hibernating, and suspending your machine.
From simple shutdown commands to scheduled actions and forceful system reboots, we’ll teach you how to master your Linux system’s state from the command line.
Table of Contents
Basics of the Linux Command to Shutdown
shutdown command is your go-to tool for controlling the power state of your Linux machine. It is used to halt, power-off, or reboot the machine. For a basic, immediate shutdown, you would use the following command –
shutdown -h now
This linux shutdown command example immediately halts the system (‘-h’ stands for halt). The ‘now’ parameter specifies that the shutdown should occur immediately.
To execute a command like this, you need to have root permissions. You might use the
sudo command if necessary.
Scheduling Shutdowns and Sending Messages
shutdown command is also versatile enough to schedule shutdowns. This gives you and other users time to save work or complete tasks before the shutdown begins. The time is specified as a parameter and can be in an absolute time (hh:mm) or a relative time (+m) where m is the number of minutes from now.
shutdown -h +60 "System will shutdown in 60 minutes, please save your work"
This command schedules a shutdown one hour after the command is issued and broadcasts the quoted message to all logged-in users.
To cancel a scheduled shutdown, use the -c option –
This command cancels a previously scheduled shutdown. Only root or a user with sudo privileges can cancel a shutdown.
Exploring Linux Shutdown Command Options
Beyond halting and scheduling, several linux shutdown command options are available to provide more control over your system. The
-r option reboots the system instead of halting it after the shutdown sequence –
shutdown -r now
This is the primary command for restarting Linux. If you want to put your machine into hibernation, use the
-H option, and for suspending the system, the
-P option is used.
How to shutdown Linux server from Putty?
If you’re managing a Linux server remotely, you might use a tool like Putty. The process to shutdown the server is still the same. Open a new Putty session, connect to your server, and run the shutdown command –
sudo shutdown -h now
What is the shutdown command for Ubuntu?
Ubuntu, being a Linux distribution, uses the same
shutdown command syntax as we’ve outlined above. You can use the shutdown, restart, hibernate, and suspend options similarly.
What is the shutdown command for Unix?
The shutdown command works similarly on Unix-based systems, though the syntax can differ slightly. On a Unix system, you could use:
shutdown -h +time &
In this command, ‘-h’ instructs the system to halt, ‘+time’ specifies when to shut down, and ‘&’ allows the command to run in the background.
How to Shutdown Linux without delay?
When you need to shut down a Linux system immediately, you can use the ‘now’ parameter:
sudo shutdown -h now
This command tells the system to shut down instantly. Note that shutting down in this way doesn’t give services and applications a lot of time to close properly, which might cause data loss in some circumstances.
Managing your Linux system’s power state is an important skill, whether you’re a new user or an experienced administrator.
In this article, we’ve covered how to use the linux command to shutdown, schedule, message users, cancel shutdowns, restart, hibernate, and suspend your system, as well as how to handle these tasks from a tool like Putty and on different distributions and Unix systems. Master these commands, and you’ll have full control over your system’s state, no matter what situation you find yourself in.