You don’t need to reboot a Linux server, they are not running only 2-3 weeks even years without interruption. Still, I am explaining the most popular commands to reboot Linux server and system.
If you are window user then you know simple way to reboot you system using graphical interface.
Linux is not one step back then windows operating system, It’s developer build up Linux with beautiful graphical interface.
So you can GUI to shutdown and reboot Linux without command line. Is it interesting? then read full article, I will share end of this article.
There are three most popular and useful command to reboot linux system, reboot command, shutdown, and init.
You can use these three command respectively to reboot the system.
- Reboot command to reboot Linux
- Reboot command options
- Other commands to reboot Linux system
- Command to reboot Linux schedule time
- Canceling Scheduled Reboot Linux
- Checking your reboot logs
Reboot Linux Command Table
|$reboot -h||Display Usage of Reboot command|
|$sudo reboot||Reboot the system|
|$sudo shutdown –r now||Reboot system istantly|
|$init 6||Reboot system|
|$sudo shutdown –r [TIME] [MESSAGE]||Display Time and Message to reboot scheduling|
|$sudo shutdown –c [MESSAGE]||Cancel Scheduling Rebook|
|$last reboot||Display reboot logs|
Reboot command to reboot Linux
Are you looking for just restart the linux system without going into any details? reboot command is very helpful at this situation. It is the easiest and quickest way to reboot linux system.
reboot command is used to restart or reboot the system. In a Linux system administration, You need to restart the Linux server in very rare conditions, for example after the completion of some network and other major updates.
You need to reboot Linux system because of changes after updation can be affected on the server.
For example, if the user is re-compiling the server’s kernel that is going through some more advanced server administration, then he needs to restart the machine in order to complete the compilation and to have a new updated kernel version on the server.
When Updating the server’s memory, IP allocation, NIC configuration are the key tasks that need to be done on the server restarted once leading to their successful implementation.
Most of the Linux system administrators are not working directly on the server, they have access to their servers via shell or SSH.
So if you are an administrator and want to perform a bunch of administrative activities, server management, and monitoring on the server, you first login on your system by using SSh server.
If you are restarting system through SSH server you must know the basic commands to restart the server from the shell.
You just help yourself by using any one of the following commands:
$sudo shutdown –r now
If your system is running through a normal user, you can use this command without sudo.
You can say a normal user can reboot without any problem.
Reboot command options
Sometimes, your system is blocking from shutting down the process, perhaps due to a runaway process, then your single reboot command will not work.
you can use the –force flag to make the system shut down anyway. Because this option skips the actual shutting down process.
–force just an option is used to a forced system for shutting down, there are some other options can be used with the reboot command.
you can use man command or following command to display all available options.
- –help : This option prints a short help text and exit.
- –halt : This option halt the machine, regardless of which one of the three commands is invoked.
- -p, –poweroff : This option will going to power-off the machine, regardless of which one of the three commands is being invoked.
- –reboot : This option reboot the machine, regardless of which one of the three commands is invoked.
- -f, –force : This option force immediate halt, power-off, or reboot. When it is specified once, this results in the immediate but clean shutdown by the system manager. When it is specified twice, this results in immediate shutdown without contacting the system manager. See the description of the option –force in systemctl(1) for more details.
- -w, –wtmp-only : This option only writes wtmp shutdown entry, it does not actually halt, power-off, reboot.
Other commands to reboot Linux system
reboot command is popular but not a single command to reboot the Linux system, here are some other command can be used to complete this task.
You can use shutdown, and init commands as well.
I have described both command separately, so you can understand, very well.
Shutdown command to reboot Linux system
The shutdown command basically used for power off the system or shutdown the machine. But you find several options to control exactly what you want.
For the example, If you want to reboot system by using shutdown command, then use -r option to reboot Linux mahine.
Use shutdown command followed by “-r now” to reboot system imediatly. The syntax will be as below:
$shutdown -r now
$sudo shutdown -r now
#shutdown -r now
Init Command to reboot Linux
Init term has been taken from the word initialize that is widely been used to initialize/start different processes in a Linux machine.
So you can use this command followed by runlevel 6. As you know, Linux Machine can understand 7 runlevels.
Different distributions can assign each mode uniquely, but generally, 0 initiates a halt state, and 6 initiates a reboot (the numbers in between denote states such as single-user mode, multi-user mode, a GUI prompt, and a text prompt).
So you will find runlevel 6 is useful for rebooting a Linux server.
The syntax for this is mentioned below:
$sudo init 6
Command to reboot Linux schedule time
As you have seen before, simple reboot command has limited usage. If you want to schedule reboot/restart on your system, reboot command is useless.
In this case, The shutdown command is being used instead of reboot command to fulfill much more advance reboot and shutdown requirements. One of those situations is a scheduled restart.
Following is the syntax which is being used to reboot your system after time defines by the TIME.
$sudo shutdown –r [TIME] [MESSAGE]
Here the TIME has various formats. The simplest one is “now”, I have already told you in the previous section. You can use it restart the system immediately.
Other valid formats we have are +m, where m is the number of minutes we need to wait until restart and HH: MM which specifies the TIME in a 24hr clock.
If you want to reboot after 10 minutes then you can use following command:
$sudo shutdown -r +10
If you want to schedule restart on specific time then use following syntax:
$sudo shutdown –r 14:20
Canceling Scheduled Reboot Linux
If you don’t want restart/shutdown system on sheduled time, you can use another shutdown command followed by –c option and broadcast with a message for the users about the cancellation of the sheduling restart.
The basic of canceling restart/shutdown as follows:
$sudo shutdown –c [MESSAGE]
The scheduled reboot can be canceled by the system administrator by simply issuing another shutdown command with the –c option and an optional message argument.
$sudo shutdown -c “our custom example of canceling a scheduled shutdown on specific time”
Checking your reboot logs
If you are working as a system administrator, then you must know how to check reboot, login, logout records. You can find all logins and logouts records inside file /var/log/wtmp.
You can use cat command to see available records in the log file.
There is another command used toe access log for the reboot is the last command. You can use the last command followed by reboot display all reboot records.
Below you can find the last command usage and syntax to display restart log.
[[email protected] ~]$ last reboot reboot system boot 4.18.0-147.5.1.e Tue Apr 14 19:13 still running reboot system boot 4.18.0-147.5.1.e Tue Apr 7 10:22 - 13:02 (1+02:40) reboot system boot 4.18.0-147.5.1.e Mon Apr 6 10:38 - 12:31 (01:52) reboot system boot 4.18.0-147.5.1.e Sun Apr 5 10:01 - 10:40 (00:39) reboot system boot 4.18.0-147.5.1.e Sat Apr 4 18:18 - 19:59 (01:41) reboot system boot 4.18.0-147.5.1.e Thu Apr 2 14:06 - 16:58 (1+02:51) reboot system boot 4.18.0-147.5.1.e Tue Mar 31 17:27 - 17:59 (00:31) reboot system boot 4.18.0-147.5.1.e Mon Mar 30 17:04 - 18:51 (01:46) reboot system boot 4.18.0-147.5.1.e Sun Mar 29 12:02 - 20:48 (08:46) reboot system boot 4.18.0-147.5.1.e Sun Mar 29 11:55 - 12:01 (00:06) reboot system boot 4.18.0-147.5.1.e Sat Mar 28 15:11 - 12:01 (20:49) reboot system boot 4.18.0-147.el8.x Sat Mar 28 13:40 - 12:01 (22:20) reboot system boot 4.18.0-147.el8.x Fri Mar 27 17:35 - 12:01 (1+18:26) reboot system boot 4.18.0-147.el8.x Fri Mar 27 17:22 - 17:34 (00:12) reboot system boot 4.18.0-147.el8.x Mon Mar 23 18:21 - 17:34 (3+23:13) reboot system boot 4.18.0-147.el8.x Sat Mar 21 11:22 - 11:27 (00:04) reboot system boot 4.18.0-147.el8.x Sat Mar 21 11:14 - 11:22 (00:07) wtmp begins Sat Mar 21 11:14:56 2020 [[email protected] ~]$
You have learned about reboot command in Linux, which is used to reboot the Linux and Unix system and server. I have described about another commands including shutdown and init to reboot the system.
You can reboot Linux system remotely by using ssh server.
If you have any questions or feedback, feel free to leave a comment.