What is reboot?
5 reboot examples
Syntax and Options
Related Commands
What is reboot?
The ‘reboot’ command in Linux is used to reboot the system. This command invokes the reboot() system call or the shutdown() system call depending on how it is used.
5 reboot Examples
1. Simply reboot the system
Just run reboot as superuser and your system will reboot after entering the superuser password.
$ reboot
2. Forcefully reboot the system
This is made possible by using the -f flag
$ reboot -f
-f flag makes sure that the shutdown utility is not invoked rather the system is rebooted in a non-graceful way.
3. The /var/run/utmp and /var/log/wtmp files
When dealing with reboot command, one must have the following information.
From the man page :
/var/run/utmp :
Where the current runlevel will be read from; this file will also be updated with the runlevel record being replaced by a shutdown time record./var/log/wtmp :
A new runlevel record for the shutdown time will be appended to this file.
4. Update the /var/log/wtmp without actual reboot
This is made possible by using the -w flag.
$sudo reboot -w $
So you will see that after running reboot with -w flag system actually did not reboot.
5. How to check the modification in /var/log/wtmp?
Since the /var/log/wtmp is a binary file so I checked the modification in this file through the cksum command. I checked the checksum before and after running the reboot command with -w flag and following were the results :
$ cksum /var/log/wtmp 2022140618 31104 /var/log/wtmp $ sudo reboot -w $ cksum /var/log/wtmp 2143754879 31488 /var/log/wtmp
So as you see above, the checksum changed, hence one can conclude that the file was indeed modified.
Syntax and Options
reboot [OPTION]...
Short Option | Long Option | Option Description |
---|---|---|
-f | –force | Does not invoke shutdown(8) and instead performs the actual action you would expect from the name. |
-w | –wtmp-only | Does not call shutdown(8) or the reboot(2) system call and instead only writes the shutdown record to /var/log/wtmp |
–verbose | Outputs slightly more verbose messages when rebooting, useful for debugging problems with shutdown. |
Related Commands
shutdown
telinit
runlevel