How to restart the Ubuntu Server using command-line

Let's check out the ways 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.

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.

Ubuntu Server as Virtual Machine on Vmware
Ubuntu Server as Virtual Machine on Vmware

Reboot Command

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.

$ reboot

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

Shutdown command

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

init command

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

Conclusion

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.

Arun Kumar
Arun did his bachelor in computer engineering and loves enjoying his spare time writing for FOSS Linux. He uses Fedora as the daily driver and loves tinkering with interesting distros on VirtualBox. He works during the day and reads anything tech at night. Apart from blogging, he loves swimming and playing tennis.

LEAVE A REPLY

Please enter your comment!
Please enter your name here

STAY CONNECTED

23,874FansLike
265FollowersFollow
16SubscribersSubscribe

LATEST ARTICLES

Create a ClamAV Antivirus Live USB drive, and how to use it

Antivirus Live CD or USB drives come in handy at times when your computer is infected with a virus and other malware. Here is how you can create a ClamAV Live USB drive to scan and remove the malware from a computer.
best laptops for linux
Apart from your programming skills, there are a few other things that can also influence the way you code, and one of them is your computer system for sure. Even though it isn't like you can't code on a regular PC or laptop, speaking from personal experience, you can make the most out of your programming skillset by going for a computer with high specs and one that's been specially designed for such tasks.
MX Linux 19 Features and Desktop Tour
MX Linux is a Linux distribution based on Debian stable and using core antiX components. The distributions MX Tools is very popular among users and combined with other several ready-to-use tools, it is great for users who prefer to tweak their distro to their liking. In this video, we will take you through the features tour showing casing MX Linux 19.