Sometimes you may need to restart or reboot Linux server from command line. In this article, we will look at how to restart Linux server from terminal or command line interface.
How to Restart Linux Server from Command Line
There are different ways to restart Linux server from command line. We will look at each of them one by one.
Open terminal and run the following command to shutdown your Linux system
If you want to reboot your machine instead, use shutdown command with -r option.
$ shutdown -r
If you do not have sufficient privileges to run shutdown command, then use sudo before the command.
$ sudo shutdown
If you want to shutdown or reboot a remote machine then use shutdown command along with ssh command. Replace server.com with the remote server’s IP or domain. Replace user with the username of remote user.
ssh –t email@example.com ‘sudo shutdown’
You will be asked to provide password for the remote user.
You can alternatively use reboot command to reboot your Linux system
If you do not have enough privileges to run reboot command, you can do so with sudo.
$ sudo reboot
You can also call reboot command on remote server using ssh command as shown below.
ssh –t firstname.lastname@example.org ‘sudo reboot’
If you want to shutdown or reboot your system at a specific date/time, you can schedule them using cronjob. Open crontab with the following command.
$ crontab -e
Add the following line to schedule reboot every day at 10.a.m.
0 10 * * * reboot >/dev/null 2>&1
Save and close the file.
In this article, we have looked at how to reboot or restart your Linux system from command line.