I’m learning a lot about how to use the Ubuntu terminal and I’m really enjoying the commands I’m learning. I wonder if it is possible to shut down the computer or reboot just using a command at the terminal?
Thank you in advance.
3 Answers
Shutting Down or Restarting the Computer via Terminal in Ubuntu
If you’re a Ubuntu user and you’re familiar with the terminal, you might be wondering if it is possible to shut down or restart your computer using just a command in the terminal. The answer is yes, it is possible! In this article, we will show you how to shut down or restart your Ubuntu computer using the terminal.
Shutting Down the Computer
To shut down your Ubuntu computer using the terminal, you can use the “shutdown” command. Here’s how:
1. Open the terminal by pressing “Ctrl + Alt + T” or by searching for “Terminal” in the applications menu.
2. In the terminal, type the following command and press “Enter”:
sudo shutdown now
3. You will be prompted to enter your password. Type your password and press “Enter”.
4. The computer will start shutting down immediately.
Alternatively, you can use the following command to shut down the computer after a certain amount of time (in minutes):
sudo shutdown +m
Replace “m” with the number of minutes after which you want the computer to shut down. For example, if you want the computer to shut down after 10 minutes, you can use the following command:
sudo shutdown +10
Restarting the Computer
To restart your Ubuntu computer using the terminal, you can use the “reboot” command. Here’s how:
1. Open the terminal by pressing “Ctrl + Alt + T” or by searching for “Terminal” in the applications menu.
2. In the terminal, type the following command and press “Enter”:
sudo reboot
3. You will be prompted to enter your password. Type your password and press “Enter”.
4. The computer will start restarting immediately.
Alternatively, you can use the following command to restart the computer after a certain amount of time (in minutes):
sudo shutdown -r +m
Replace “m” with the number of minutes after which you want the computer to restart. For example, if you want the computer to restart after 10 minutes, you can use the following command:
sudo shutdown -r +10
Canceling a Shutdown or Restart
If you have started a shutdown or restart process using the terminal and you want to cancel it, you can use the “shutdown” command again. Here’s how:
1. Open the terminal by pressing “Ctrl + Alt + T” or by searching for “Terminal” in the applications menu.
2. In the terminal, type the following command and press “Enter”:
sudo shutdown -c
3. The shutdown or restart process will be canceled immediately.
Using the “halt” Command
The “halt” command is another command that you can use to shut down your Ubuntu computer. This command shuts down the computer without performing any additional tasks, such as unmounting file systems or notifying users. Here’s how to use it:
1. Open the terminal by pressing “Ctrl + Alt + T” or by searching for “Terminal” in the applications menu.
2. In the terminal, type the following command and press “Enter”:
sudo halt
3. You will be prompted to enter your password. Type your password and press “Enter”.
4. The computer will start shutting down immediately.
Using the “poweroff” Command
The “poweroff” command is similar to the “halt” command, but it also turns off the computer’s power. Here’s how to use it:
1. Open the terminal by pressing “Ctrl + Alt + T” or by searching for “Terminal” in the applications menu.
2. In the terminal, type the following command and press “Enter”:
sudo poweroff
3. You will be prompted to enter your password. Type your password and press “Enter”.
4. The computer will start shutting down and will turn off completely when the process is complete.
Conclusion
Shutting down or restarting your Ubuntu computer using the terminal can be a useful skill to have, especially if you need to shut down or restart your computer quickly or if you prefer to use the terminal over the graphical user interface. With the commands we’ve discussed in this article, you should be able to shut down or restart your Ubuntu computer using just a few simple commands.
In the latest versions of Ubuntu you don’t need to use sudo.
To shutdown:
poweroff
To reboot:
reboot
Hi, this is easy and useful.
Here the most generic commands to do both shutdown and reboot:
To shutdown the system:
sudo shutdown -h now
Or:
sudo shutdown -r now
Or:
sudo halt
Or:
sudo init 0
For reboot:
sudo reboot
Or:
sudo init 6
To learn more shutdown options, see the command help:
shutdown --help
Or:
man shutdown
Enjoy! ;)