Home Beginner's Guide How to restart the Ubuntu Server using command-line

How to restart the Ubuntu Server using command-line

by Arun Kumar
Restart Ubuntu Server

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.

[fosslinux-server@dhcppc1 ~]# 
Broadcast message from root@dhcppc1
        (/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.

You may also like

Leave a Comment

fl_logo_v3_footer

ENHANCE YOUR LINUX EXPERIENCE.



FOSS Linux is a leading resource for Linux enthusiasts and professionals alike. With a focus on providing the best Linux tutorials, open-source apps, news, and reviews written by team of expert authors. FOSS Linux is the go-to source for all things Linux.

Whether you’re a beginner or an experienced user, FOSS Linux has something for everyone.

Follow Us

Subscribe

©2016-2023 FOSS LINUX

A PART OF VIBRANT LEAF MEDIA COMPANY.

ALL RIGHTS RESERVED.

“Linux” is the registered trademark by Linus Torvalds in the U.S. and other countries.