Skip to Content

4 Ways to check last reboot time in Linux

In this blog post, we will be discussing four different ways to check the last time your Linux system was rebooted. This information can be useful for troubleshooting purposes, or simply to keep track of how often your system is being rebooted.

We will be using the terminal commands “last,” “who -b,” “uptime -s,” and “dmesg” to obtain this information. Let’s get started!

Check the last reboot time with last command in Linux

The best way to check the last reboot time in Linux is using the last reboot command. Open the terminal and type last reboot. It will show all reboots since the log file was created. To list the last reboot time, run last reboot| head -2.

Example:
# last reboot|head -2
reboot   system boot  4.18.0-348.20.1. Mon Aug 29 08:43   still running
reboot   system boot  4.18.0-348.20.1. Mon Aug 29 08:27 – 08:38  (00:11)

The last command by default will show you a list of all the users who have logged in and out of the system. It searches back through the file /var/log/wtmp and displays a list of all users logged in (and out) since that file was created. This command also lists the system shutdown time and reboot time.

To get the last shutdown time, we can run last shutdown|head -2.

Check the last reboot time with uptime command in Linux

The uptime command is a great option to check the last reboot time in Linux. This command will show you how long the system has been running. It will also show you the time of the last reboot with uptime -s command.

The drawback to this method is that it only shows you information about the current boot. If you want to see information about previous boots, you will need to use another method.

Example:
# uptime -s
2022-08-29 08:43:19

check the last reboot time with who command in Linux

The who command is a great way to see all the users who are currently logged in to the system. To check the last reboot time, we can use the -b switch with who. This will show us when the system was rebooted.

The drawback to this method is that it only shows us information about the current boot. If you want to see information about previous boots, we need to use another method.

who -b
System reboot time: Sun Jun 16 05:12:39 2022

Check the last reboot time with dmesg command in Linux

We can also check the last reboot time in Linux with the dmesg command. This command is used to print or control the kernel ring buffer. The kernel ring buffer is a data structure that stores information about the kernel’s activity.

To view the last reboot time, we can run dmesg | grep “systemd-” | head -n 20.

This will show us the last 20 lines that contain the word “systemd”. We can see from the output that the system was rebooted on June 16 at 05:12:39.