If you are downloading a massive file or running a long compilation script on your Linux machine before bed, you probably don’t want the computer to stay powered on all night after the task finishes. Leaving your machine running constantly wastes electricity and generates unnecessary heat.
Thankfully, Linux comes with a built-in shutdown command that allows you to easily schedule exactly when the system should power off, without needing any third-party software.
How to Schedule a Shutdown
Open your terminal and use the shutdown command followed by the time you want the computer to turn off. You can specify a relative time (in minutes) or an absolute time (in 24-hour format).
To shut down in a specific number of minutes:
Use the +m format. For example, to shut down the computer in exactly 45 minutes, type:sudo shutdown +45
To shut down at a specific time:
Use the hh:mm format. For example, to schedule a shutdown for 11:30 PM (23:30), type:sudo shutdown 23:30
After pressing Enter, Linux will broadcast a message to all logged-in users warning them that the system is going down, and it will automatically power off at the scheduled time.
How to Cancel a Scheduled Shutdown
If your download finishes early or you simply change your mind, you can easily abort a scheduled shutdown.
Open your terminal and type:sudo shutdown -c
The -c flag stands for “cancel.” The system will instantly abort the timer, and your computer will remain powered on.