Shutting down and restarting a computer is too common a task. It is also quite simple thanks to the numerous options in the graphical interfaces. But there is one option that is not always present and that is to program shutdown in Linux. This is especially useful if we manage servers or remote computers or simply leave a task on our computer and we have to leave. So in this post, we’ll show you how to program shutdown in Linux. You can apply this to any Linux distribution.
As you well know, shutting down a computer correctly helps the hardware not suffer. This way you will protect the hard disk, the power supply, and other things. On the other hand, some security updates require at least one reboot to apply the changes. Of course, this in terms of servers, has evolved exponentially.
So let’s go for it.
Shutdown in Linux
Let’s start at the beginning. The command that allows you to shut down a Linux system is the shutdown command. So its operation is quite simple. However, to run it, in some cases, you need to have root privileges.
If you want to shut down the computer immediately, you can use this command:
:~$ sudo shutdown now
As simple as that, as you can see.
Now, we can also program shutdown in Linux using this same command. The trick is to directly specify the time we want it to be done.
:~$ sudo shutdown 13:30
The previous command brings a consequence that the system will be turned off at 13:30 closer to the local time.
Another way to turn off the program on Linux is to tell the command a defined time. For example, we want the system to shut down within 40 minutes. To do this, we follow this command:
:~$ sudo shutdown +40
That’s enough. Now let’s see how to reboot the system.
That’s enough. Now let’s see how to reboot the system. To do this, just add the -r argument to the shutdown command.
If you want to schedule a restart at a certain time, run the following command:
:~$ sudo shutdown -r 12:30
On the other hand, if you want to do it in a certain amount of minutes, use the following command:
:~$ sudo shutdown -r +20
Finally, if you have programmed shutdown in Linux and want to cancel it. Use the following command:
:~$ sudo shutdown -c
And that’s it.
Conclusion
Programming off in Linux is one of those tricks quite useful for the use of the system. So we can schedule tasks and then shut down the computer, even on a small server or local is of maximum benefit.
You can also read about the ls command or the CURL command.
Please share this post with your friends.