Every operating system, whether being used as a personal computer or as a server, maintains a log of the shutdown, reboot, and login times. This is not only important for system administration, but also for troubleshooting problems.
In Linux, all logs are stored in the ‘/var/log/’
directory. The details about logged-in users and respective shutdown, reboot, and login times are also stored here.
Let’s see how we can find out the last reboot time in Ubuntu.
Using Last Command
We can run the command last with the parameter ‘reboot’ to get the time and date of the last reboot.
$ last reboot

As seen above, the list of last reboots is displayed. To just display the latest reboot, filter the output with the ‘head‘ command.
$ last reboot | head -1

We thus know that the Ubuntu system was last rebooted on Wednesday, Jan 6th at 14:37.
Using Who Command
The who command in Linux displays information about the logged-in user.
$ who

As shown above, it displays the logged in user name, the ID (:0)
, the login time, and the remote or local display ID (:0)
.
If we execute this command with the '-b'
flag, it displays the time and date of the last reboot.
$ who -b

Using Uptime Command
The uptime command displays the uptime of the system, i.e., how long has the system been running. It outputs in the length of time the system has been running.
$ uptime

We can pass the argument '-s'
to output the last time the system was booted.
$ uptime -s

User can also pass an argument '--since'
which gives the same result as '-s'
.
Conclusion
In this article, we looked at the ways of finding the last reboot time in Ubuntu. Apart from simply viewing the time, an advanced user/administrator can also make use of the output of the above commands in a script.
If you have any questions or feedback, make sure you leave a comment below!