How to Shut Down Your Computer Using the Linux Terminal
The command required to shut down your machine is as follows:
The command required to shut down your machine is as follows:
shutdown
It is highly likely that you need to have elevated privileges to use the shutdown command, so you are more likely to use the sudo command as follows:
sudo shutdown
The output from the above command will say something along the lines of "shutdown scheduled for , use shutdown -c to cancel".
Timing Your Shutdown
Generally, it's better to specify when you want the computer to shut down. If you want the computer to shut down immediately, use the following command:
sudo shutdown now
The time element can be specified in a number of ways. For example, you could use the following command to shut down the computer immediately:
sudo shutdown 0
The number refers to the number of minutes to wait before the system attempts to shut down.
Incidentally, the command sudo shutdown without any time element is the equivalent of running the following command:
sudo shutdown 1
The default is 1 minute.
You can also specify a set time in hours and minutes to shut down your computer as follows:
sudo shutdown 22:00
When the amount of time until shut down is less than 5 minutes, the system will not allow any more users to log in.
Other Shutdown Switches
If you are running a system with multiple users, you can specify a message which will appear on all user screens, letting them know that a shutdown is going to occur.
sudo shutdown 5 "save your work, system going down"
For completeness, there is another switch you can use as shown below:
sudo shutdown -P now
Technically, you don't need to use the -P parameter, as it actually stands for power off and the default action for the shutdown is to power off. If you want to guarantee that the machine powers off and doesn't just halt then use the -P switch.
If you are better at remembering words over switches, you might prefer to use the following:
sudo shutdown --poweroff now
How to Reboot Your Computer Using the Linux Command Line
The command for rebooting your computer is also shutdown. There is actually a reboot command as well which is used for legacy purposes. Logically speaking, it's a more obvious command to use to reboot your computer, but most people actually use the following command to reboot their computer:
sudo shutdown -r
The same rules apply to the reboot command as they do for the shutdown command.
What this means is that by default, the shutdown -r command on its own will reboot the computer after 1 minute.
To reboot immediately, you have to specify the following command:
sudo shutdown -r 0
If you want the computer to reboot in 5 minutes you can specify the following command:
sudo shutdown -r 5
You can also specify a time to reboot the computer in hours and minutes as follows:
sudo shutdown -r 22:00
Finally, as with the shutdown procedure, you can specify a message to be displayed to all users of the system, letting them know the system is going down.
sudo shutdown -r 22:00 "the system is going to bounce. Boing!!!"
If you prefer, you can use the following instead of the -r switch:
sudo shutdown --reboot now
Make the System Halt
You can specify one more command which shuts down the operating system, but doesn't actually power off the machine.
The command is as follows:
sudo shutdown -H
You can also use the following command:
sudo shutdown --halt
How to Cancel a Shutdown
If you have scheduled a shutdown for the future, you can cancel the shutdown using the following command:
shutdown -c
If you have used either shut down now or shutdown 0 then this won't have time to work.
Create a Keyboard Shortcut to Shut Down Ubuntu
If you are using Ubuntu, you can easily create keyboard shortcuts to shut down and reboot your computer.
1. Press the super key (key with the Windows symbol on it) on your keyboard and type the word "keyboard".
When the keyboard icon appears, click on it.
The keyboard application will load. There are two tabs:
◈ Typing
◈ Shortcuts
2. Click on the Shortcuts tab and click the plus symbol at the bottom of the screen to add a new shortcut.
Enter Shutdown Computer as the name and type the following as the command:
gnome-session-quit --power-off --force
Click Apply.
3. To assign the shortcut click on the word disabled next to Shutdown Computer and hold down the keys you wish to use. (For example, CTRL and PgDn).
4. To add a keyboard shortcut to reboot your computer press the button with the plus symbol again and this time enter Reboot Computer as the name and the following as the command:
gnome-session-quit --reboot --force
Click Apply.
5. To assign the shortcut, click on the word disabled next to the words Reboot Computer and press the keys you wish to use as the shortcut. (For example, CTRL and PgUp).
What you will notice is that when you press the keyboard shortcut, a little window will pop up asking what you want to do anyway, so you can get away with one keyboard shortcut for both commands.
It's worth pointing out that you can already use a keyboard shortcut for logging out. As you might have guessed, those are CTRL, ALT and Delete, the same as Windows.
0 comments:
Post a Comment