Ubuntu server is growing popular every day. Thanks to containers and cloud computing. For small businesses and organizations looking for an affordable server solution, the Ubuntu server is the way to go. It works well with practically all hardware and virtualization platforms.
Currently, 37% of websites online run on Linux servers, and of that percentage, the Ubuntu server takes 35.9%. It wouldn’t be a surprise to realize that Ubuntu powers your website. Even Microsoft cloud platform Azure makes use of Ubuntu server images.
In this particular article, we are going to look at a few Ubuntu server terminal commands – how to restart the Ubuntu server via command-line. Most of the network administrators, engineers, or anybody managing an Ubuntu server, there is a high probability they don’t use the Graphical User Interface (GUI) utility. It’s either they execute commands directly on the server command-line or access it remotely via SSH using applications like Putty.
Restarting Ubuntu Server using command-line
We will be looking at all the commands you can execute to restart your Ubuntu server. Some of these commands can also work on the Ubuntu desktop version. For this post, we have Ubuntu Server 18.04 LTS running as a virtual machine on my Ubuntu desktop.
It is so far the most straightforward method one can use to restart the Ubuntu server. Not only does it work for the Ubuntu Server, but also Ubuntu desktop and other Debian based Linux distributions.
In case you run the above command, and you get an error like “permission denied,” then you don’t have elevated privileges. You will have to add the sudo command. It’s illustrated below.
$ sudo reboot
This action will prompt you to enter your administrator password. Type your password and hit enter.
There is one more parameter you can add to this reboot command – the now command.
$ sudo reboot now
In case there are background running services, but you want to reboot the server, use the -f parameter, which means forcefully restart the server.
$ sudo reboot -f
The shutdown command by itself is used to power-off your Ubuntu server. However, with an additional -r parameter, you can use it to restart your server or even the Ubuntu desktop. You might need to have elevated privileges, therefore, use the sudo command.
$ sudo shutdown -r
This command comes with a few more parameters that might be useful for your overall experience with the Ubuntu server. One of them is that you can set the server to reboot after a specific duration in minutes.
$ sudo shutdown -r +10
The above command will reboot your server after 10 minutes.
Any other logged-in users will see a message similar to the one below on their Terminal.
[[email protected] ~]# Broadcast message from [email protected] (/dev/tty1) at 18:00 ... The system is going down for reboot in 10 minutes! Server will restart in 10 minutes. Please save your work.
You can also set a particular time that you want the server to reboot. You will need to specify the time the format of HH: MM.
$ sudo shutdown -r HH:MM e.g $ sudo shutdown -r 18:00
The above command will reboot my server at exactly 6:00 pm.
In case you want to cancel a set reboot schedule, execute the shutdown command, but remember to add the -c parameter.
$ shutdown -c
One more parameter we can use with the shutdown command is now. This means to reboot the server immediately.
$ sudo shutdown -r now
The init command is used to perform several actions depending on the parameter given. The parameters are numbers 0 to 6 referred to as run levels. Run level 0 brings down/halt the system while run level 6 restarts the system.
sudo init 6
Those are three ways that you can use to reboot your Ubuntu server using commands. They can also be executed remotely via SSH using applications like Putty. If you are running a desktop version of any Debian-based distribution, these commands can also come in handy.
Is there is a command that you use and not listed above? Feel free to let our readers know in the comment section below. If you find this article useful, don’t forget to share the link with friends.