Here’s how to restart ubuntu from the command line

Here’s how to restart Ubuntu from the command line

Although Linux does not require frequent reboots, unlike Windows, sometimes major system updates or serious system errors require a system reboot. With the introduction of ‘kptach’ from RedHat, system administrators can easily patch critical security updates to the Linux kernel. You don’t have to search for the processes to complete them, log out of the system, or start a reboot task. It also increases system availability without losing productivity. Ubuntu’s Livepatch also works the same way. With Livepatch, vulnerability fixes can be patched on the Ubuntu Linux kernels.

Sponsored

The restart process helps terminate blocked programs, apply critical patches, remove temporary files, repair damaged file systems, and perform many system administration tasks.

What are we going to cover?

In this guide we see different ways to restart a Linux Ubuntu 20.04 computer using the command line and GUI. Let’s start with this tutorial.

Use the shutdown command

This command can be used to stop, turn off, or restart a machine. It takes a time argument to indicate the time to run. The time argument is ‘now’ to trigger an immediate operation. For example, to restart a system immediately, use the ‘-r’ flag with the ‘now’ string:

$ sudo switch off -R now

If you want to schedule a restart after 5 minutes, use the following command in the same way:

$ sudo switch off -R 5

The time format is “hh: mm” in 24-hour format. We can also use ‘+ m’ to restart after ‘m’ minutes from now on.

See also  How to Install GUI on Ubuntu Server

It should be noted that the shutdown command itself also has the ability to shutdown, restart, stop, and power off a system.

Using the restart command

From the terminal’s point of view, the reboot command is the fastest and easiest way to reboot a system. Just enter the following command to reboot:

$ start anew

In fact, it’s short for ‘shutdown -r now’.

With ‘Init’ the command

On Linux, ‘/ sbin / init’ is the first process to run after the kernel is loaded. This means that the process has PID 1.

In Linux systems without ‘systemd’, the ‘init’ command stops all running processes and the disks are then synchronized before the init states or runlevels are changed. Runlevel 5 is the standard runlevel. The ‘init 6’ command stops the running system and reboots the system in a state that is listed in ‘/ etc / inittab’. To restart just use:

$ sudo inside 6th

In case we want to restart the Linux Ubuntu in a multi-user state, use the command:

$ sudo inside 2

To reboot into a single user state (runlevel S), use the command in a similar way:

$ sudo in his

To reboot into single user mode use the command:

See also  Ubuntu 23.10 (Mantic Minotaur) Beta released
Sponsored
$ sudo /sbin/inside 1

Run the following command to check your current runlevel:

$ Runlevel

If the output is like ‘N 1’, it means we don’t have an old runlevel because we just booted the system:

Now let’s boot to runlevel 1 (also called runlevel s) and check the runlevel status:

As you can see, the status has now changed to ‘5 1’. We can switch back to runlevel 5 again by doing the following:

$ sudo /sbin/inside 5

The ‘SYSTEMD’ way

‘Systemd’ has replaced the init process, so ‘/ sbin / init’ is now a symbolic link to systemd.

You may not find ‘/ etc / inittab’ on systems with systemd (as opposed to the init system). In such a case, use the following command to reboot a system:

$ sudo Systemctl restart

Just like runlevel in the SysV init system, systemd uses the so-called “target” system. The ‘systemctl’ command above is the primary interface to systemd. Runlevel 6 of the SysV init system has its equivalent target in systemd as “reboot.target”. So you can also use the above restart command as:

$ sudo systemctl isolate rescue.target

The restart button

The easiest and fastest solution is of course the reboot button. If you click on the top right corner of your Ubuntu 20.04 system, you will find the “Power Off / Log Off” option.

Now when you click that option, the last option will show up as “Turn Off”. Press this label and the Power Off window will open. Click the Restart button to restart the system.

You can also find this window by typing ‘reboot’ in the Gnome search bar:

Another option is to use the physical power button. This will bring up the Power Off window. Please note, however, that the behavior of the power switch may first have to be configured in the system settings.

diploma

In this guide, we learned about different ways to restart an Ubuntu computer. In addition to Ubuntu, these instructions can also be used for many other Linux distributions, as all commands are generally the same for them. We didn’t provide many screenshots of the hands-on exercises as it won’t reboot. But we are sure that this guide will work for your system without a hitch.


Discover more from Ubuntu-Server.com

Subscribe to get the latest posts sent to your email.

Comments

No comments yet. Why don’t you start the discussion?

    Leave a Reply