Reboot or Restart Linux

How to Reboot or Restart Linux

As a Linux administrator, you might need to reboot, halt, or power off your machine. For example, while facing hardware issues, installing applications, and more you will need to reboot your Linux system. Join us with this article to learn How to Reboot or Restart Linux. Obviously, you must be a root or a member of the wheel group to be able to run the reboot command. In the end, you will see that saying ”restart a server solves various issues” is not just a sentence to get rid of complex solutions, it is a holy fundamental rule in the computer engineering world!

To have a fresh and updated system, all the required command lines will be explored in this guide to help you reboot/restart your Linux system.

Prerequisites to Restart or Reboot Linux from the Command Line

To let this tutorial works correctly, provide the options below.

  • A system running Linux operating system.
  • A non-root user with sudo privileges.
  • Access to a command-line/terminal interface.
  • SSH software package for communicating with a remote server (optional)

Tutorial Reboot Linux (Restart)

Let’s go through the steps of this guide and review the command prompt to reboot Linux or restart. Open the terminal window or login to the remote box using ssh client to test and run the following commands of this guide.

1- Shutdown Command

Certainly, powering off is one of the most basic functions especially when you need to shut down or restart Linux via the terminal. On Linux, you can only use shutdown commands if you have the required administrator privileges. On some Linux systems, you can avoid this by appending the “sudo” command before the Linux shutdown command.

shutdown [OPTION] [TIME] [MESSAGE] is the syntax of the Linux shutdown command. Regardless of what distribution you are using, the command below will work.

sudo shutdown -r

As you guess, the -r switch indicates that you want the machine to restart. Use the command below to restart Linux immediately.

shutdown -r 0

Also, the following is a frequently used command for restarting Linux immediately:

shutdown -r now

To shut down Linux in under a minute, run:

shutdown -h

You can use the following command to shut down Linux immediately:

shutdown -h 0

In this way, Linux will immediately be shut down. There is another command that enables you to shut down Linux immediately:

shutdown now

For multi-user setups, the normal Linux shutdown command with the one-minute time delay is extremely helpful. A wall message notifying users that the system will soon be shut down or restarted can be set up in this case by the network administrator. The procedures for promptly shutting down or restarting Linux are typically just as straightforward if it is only being used on a single computer.

To power off Linux, type:

shutdown -P

This command clearly states that the primary power supply will be cut off and the system will be shut down.

As an administrator, you can use a wall message (information that is displayed on the screen of the operating system users) to let users be aware that the system is being shut down. To do this, run:

shutdown 'WRITE YOUR WALL MESSAGE HERE'

All essential Linux shutdown commands were explained.

2- Restart Linux Using Reboot Command

To restart your Linux system, open the terminal and type:

reboot

In the event that you are informed that your privileges are insufficient, type:

sudo reboot

All open applications on your system must be closed and restarted.

3- Systemctl Command Using systemd

To restart or reboot Linux, most modern Linux distro such as Debian, Ubuntu, CentOS, RHEL, Fedora, and Arch, uses systemd. Let’s see how to use systemd commands to reboot the Linux system.

sudo systemctl reboot

It will restart the system immediately. All processes and users who are currently logged in are informed that the system is going down and that no new logins are permitted when the reboot procedure is started. Linux will restart the system, close all open files, and end all operating processes. Run the reboot command with the --no-wall option to stop it from delivering a message:

sudo systemctl --no-wall reboot

Use the --message= option to set a customized message outlining the cause for the reboot:

sudo systemctl --message="Hardware upgrade" reboot

Next, the message will be shown in the logs:

System is rebooting (Hardware upgrade)

Also, you can boot into the firmware system using the systemctl. On contemporary servers, laptops, and desktops, it is feasible to reboot the system into the firmware (BIOS) setup interface. Note that not all platforms support this functionality. The syntax is:

sudo systemctl reboot --firmware-setup

How to Reboot Remote Linux Server

So far, you reviewed all important commands to Reboot or Restart Linux. Open Command Prompt and follow the below path to learn how to reboot your remote Linux server:

If you have a graphical interface, open the terminal by right-clicking the Desktop > left-clicking Open in the terminal. You can also click the main menu, and then click Applications > System Tools > Terminal. If you prefer using a keyboard shortcut, press Ctrl+Alt+T.

Then, to use the SSH connection issue reboot command, run the following command in your terminal window:

ssh -t user@server.com 'sudo reboot'

OR

ssh root@remote-server-com /sudo/shutdown -r now

Type the password of the username you have chosen when you are prompted.

You can get a notification when remote-server-com comes online by running:

ping -a remote-server-com

To use the sudo command along with a normal user over an ssh session, run:

ssh -t vivek@remote-server-com /sbin/reboot

How to schedule Linux shutdowns and restarts

Linux shutdowns and restarts can also be simply scheduled to happen at a specific time or after a specific amount of time. As seen in the following cases, you must multiply this by the duration in minutes or the time that has passed since the relevant Linux shutdown command.

To shut down Linux after 30 minutes, run:

shutdown -h 30

Linux will shut down 30 minutes after the command is entered. The command below is sometimes more commonly used and produces the same result:

shutdown +30

To restart Linux after 30 minutes, type:

shutdown -r 30

In this way, Linux will restart 30 minutes after the command is entered. To use the plus sign with this command:

shutdown -r +30

And to shut down Linux at 3:30 a.m.

shutdown -h 03:30

In Linux, time is specified using the 24-hour format in accordance with the syntax (hh:mm). In this instance, Linux is turned off at 03:30 a.m. (i.e. 03:30). Once more, you can remove the “-h” option, which denotes turning a system off or off completely:

shutdown 03:30

Use the following command to restart Linux at 03:30 a.m.

shutdown -r 03:30

At 03:30 a.m., Linux will start again. The “-r” option, which stands for “reboot,” is definitely required in this situation since without it, Linux would shut down without rebooting.

Finally, you can cancel scheduled shutdowns or restarts by running the command below. This requires that the process has not yet started.

shutdown -c

Your operating system can be stopped, shut down, and restarted by entering short instructions into the Linux terminal.

Get help about the reboot or systemctl command

So far, you learned all the required commands to Reboot or Restart Linux. It is easy to get help about reboot and systemctl commands. Just run as follows:

man reboot
man systemctl
man shutdown
reboot --help
systemctl --help

FAQ

Stopping a system and turning it off are two different things. All the processors (CPUs) are halted when you stop it, but it is also disconnected from the primary power source when you turn it off. The stopping and turning off of a system is generally recognized to be the definition of "shutdown."

The legacy reboot command is used to restart the system. The majority of Linux distributions still offer it.  systemctl reboot is a more recent command used to reboot the system and control the service manager and systemd system.

Conclusion

In this article, you learned How to Reboot or Restart Linux. Reboot/Restart Linux system is really simple. Before restarting your Linux system, make sure to save all your work. Instead of manually entering Linux shutdown commands, you can use software to install a graphical user interface.

If you encounter any problems, please do not hesitate to contact us. Our technical support team will try their best to solve your problems.

Leave a Reply

Your email address will not be published. Required fields are marked.