How to Check Shutdown and Reboot Date in Linux

Spread the love

There are plenty of reasons why you’d want to find out when your Linux computer shut down, restarted, or how long it’s been running. Most of the time this information is invaluable in debugging a problem that may have happened when no one was looking. Thankfully, Linux meticulously logs system events automatically on most distributions. Accessing that logged information from the command line is a breeze as well.

Last Boot

First, if you want to check when your computer last booted up, you can use the who command with the -b flag to get an exact date and time in your terminal. You don’t need root privileges, so go ahead and check.

who -b

Also read: Set Alarm to Automatically Power On Linux Computer

Reboots

With the last command you can list every time your system has rebooted. These aren’t necessarily times when the system has used the reboot command or that you’ve rebooted from your desktop. Instead, it logs every time your system booted.

last -x reboot

Last Reboot

If you’d prefer a more concise version, only showing the last time your computer booted, you can pipe the output to head and supply it with -1, telling it to only output one line. If you’d prefer the boot prior to your current one, use -2 to get both lines.

last -x reboot | head -1

Shutdowns

The last command works similarly with shutdowns. These are times that your computer shut down completely. They provide a time range when the computer was off. You can line these up with the reboots to know which shutdown corresponds.

last -x shutdown

Last Shutdown

Like with the reboots before, you can pipe the output to head to get the last shutdown only. Also like before, you can supply a different number, like -3 to get the last three shutdowns.

last -x shutdown | head -1

Uptime

Finally, when you want to know how long your computer has been running, you can use the uptime command to find out. Combine it with the -p flag to get much more easily readable output. You’ll get the amount of time in days, hours, and minutes that your computer has been on since the last boot.

uptime -p

Hopefully, with the above commands, you’ll be able to figure out a pattern, or even the cause, behind your computer’s reboots and shutdowns. If other programs are involved, you can always check for specific log files in “/var/log.”

Subscribe to our newsletter!

Our latest tutorials delivered straight to your inbox

Sign up for all newsletters.
By signing up, you agree to our Privacy Policy and European users agree to the data transfer policy. We will not share your data and you can unsubscribe at any time. Subscribe


Nick Congleton

Nick is a freelance tech. journalist, Linux enthusiast, and a long time PC gamer.

Comments are closed