This tutorial demonstrates several ways to turn off or restart our computers directly using commands from the terminal.
This allows us to save time and execute the shutdown or restart task easily and quickly with commands.
Commands to Shutdown or Restart Linux
It should be noted that the execution of these commands must be done with root permissions.
It is one of the commands best known for its simplicity and effectiveness.
The syntax to use with shutdown is as follows:
shutdown [option] [time] [message]
For example, if we want the equipment to turn off in 10 minutes we will use the following syntax:
shutdown -h 10
If we want to display a specific message indicating that the device will be turned off, we will use the following syntax:
shutdown -h 10 "The computer will be turned off, please save your work"
To see all the options of this command we will execute the following:
To restart the computer we will execute the following syntax.
shutdown -r +3
The -h parameter allows us to stop the machine. If we execute the halt command exclusively, the computer will turned off immediately without the possibility of preventing it.
This command fulfills the fundamental role of turning off the machine, but with the difference that it will take much longer to write the changes before proceeding with the shutdown of the equipment.
With this command we can use two additional parameters:
-f (force poweroff) -w (log the shutdown in /vat/log/wtmp)
This command is basically restart the computer and has parameters for the shutdown of the same.
The basic syntax of the command is reboot and as soon as you press enter it will start the process of restarting the machine.
When executing reboot without any additional parameters the system will be switched off and on again. We can use any of the following parameters:
reboot -p allows us to restart the system and not activate it again. reboot - f forces the restart of the computer.
There we can close the session to refresh the operating system.
These options are practical and useful for shutting down or restarting Linux on a different way.