Reboot or Restart Linux Simple Step By Step Guide
Reboot or restart Linux to safely refresh your system, apply updates, or resolve issues. Use terminal commands like reboot, shutdown -r, or systemctl reboot for a clean system restart.
🤖AI Overview:
Reboot or restart Linux involves using command-line instructions such as reboot, shutdown with the -r option, or systemctl reboot. These commands require sudo or root privileges and ensure all processes close properly for a clean system startup. This approach helps maintain system stability and apply necessary updates efficiently.
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 [email protected] '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
Conclusion
Rebooting or restarting Linux is a vital skill for system maintenance, troubleshooting, and applying updates. Whether you prefer using command-line tools like reboot, shutdown, and systemctl or the graphical interface, you can safely restart your Linux system following the guidelines provided in this article. Remember to follow best practices such as saving work, notifying users, and avoiding forced reboots to maintain system stability and data integrity.
Mastering how to reboot or restart Linux will give you confidence in managing Linux systems, whether personal computers, servers, or remote machines. With practice, these commands and techniques will become a natural part of your Linux administration toolkit.
FAQ
2. What commands can I use to reboot Linux?
Use "sudo reboot", "sudo shutdown -r now", or "sudo systemctl reboot" for restarting.
3. Do I need special permissions to reboot Linux?
Yes, root or sudo privileges are required to run reboot or shutdown commands.
4. How can I schedule a reboot in Linux?
Use "sudo shutdown -r +time" or specify a time like "sudo shutdown -r 03:30".
5. Can I reboot a remote Linux server?
Yes, use SSH with commands like "ssh user@server 'sudo reboot'" and consider SSH keys for security.
6. What is the difference between reboot, shutdown -r, and systemctl reboot?
"Reboot" restarts immediately; "shutdown -r" schedules and alerts users; "systemctl reboot" uses systemd for safe restart.
7. How do I notify users before rebooting?
Use "sudo shutdown -r" with a message option to inform users before restarting.
8. How do I cancel a scheduled reboot?
Run "sudo shutdown -c" before the reboot occurs to cancel it.
9. Why save work before reboot?
Rebooting closes applications, so unsaved data will be lost.
10. How can I get help with reboot commands?
Check manual pages with "man reboot", "man shutdown", or use "--help options".