What is reboot?
5 reboot Examples
1. Simply reboot the system
Just run reboot as superuser and your system will reboot after entering the superuser password.
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 :
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.
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
Syntax and Options
|Does not invoke shutdown(8) and instead performs the actual action you would expect from the name.
|Does not call shutdown(8) or the reboot(2) system call and instead only writes the shutdown record to /var/log/wtmp
|Outputs slightly more verbose messages when rebooting, useful for debugging problems with shutdown.