If you want to know when you did your last reboot on your Linux box, it’s actually pretty easy. This article explains how. I’m still not feeling quite up to snuff, so a quick and easy article is the call for the day!
You can run uptime
in the terminal, and that will tell you how long your system has been up and running. The output will look something like this:
1 2 | kgiii@kgiii-lmde:~/Downloads$ uptime 20:43:16 up 8 days, 20:56, 2 users, load average: 0.00, 0.01, 0.00 |
At this point, you could do the math and find your last reboot time. Of course, this being Linux, there’s an easier way to do this. This will be a quick (and easy) article and hopefully I’m doing a bit better tomorrow.
Find Last Reboot:
Like so many of these things, we need to start with the terminal open. You can do that by using your keyboard. Just press
With that open, you can start with:
1 | last reboot |
Which will give you an output similar to:
1 2 3 4 5 6 7 | kgiii@kgiii-msi:~/Downloads$ last reboot reboot system boot 5.11.0-25-generi Fri Aug 6 19:29 still running reboot system boot 5.8.0-63-generic Tue Aug 3 22:24 still running reboot system boot 5.8.0-63-generic Fri Jul 30 21:12 - 22:24 (4+01:12) reboot system boot 5.8.0-63-generic Thu Jul 29 20:00 - 21:11 (1+01:11) reboot system boot 5.8.0-59-generic Wed Jul 14 14:01 - 20:00 (15+05:58) ... |
But, the command’s usefulness doesn’t stop there. No, no it does not! You can modify the command in a couple of ways to get some more refined response. Let’s say you only want the last three results? If so, you’d use this command:
1 | kgiii@kgiii-msi:~/Downloads$ last reboot | head -3 |
This will give you an output like this:
1 2 3 | reboot system boot 5.11.0-25-generi Fri Aug 6 19:29 still running reboot system boot 5.8.0-63-generic Tue Aug 3 22:24 still running reboot system boot 5.8.0-63-generic Fri Jul 30 21:12 - 22:24 (4+01:12) |
You can also use ‘grep’ for your refining needs. Let’s say you want to know when you last rebooted in the month of May? Well, you can easily do that!
1 | last reboot | grep May |
The output of which would look similar to this:
1 2 3 | reboot system boot 5.8.0-53-generic Sat May 22 13:28 - 14:01 (10+00:33) reboot system boot 5.8.0-53-generic Wed May 12 15:11 - 13:27 (9+22:16) reboot system boot 5.8.0-50-generic Sat May 1 19:20 - 15:11 (10+19:50) |
And, there you see it. As you can see, there were three reboots in the month of May on that box. This information may be useful for debugging reasons or even compliance reasons. How you use the information is up to you! Ain’t my job to tell you how.
Closure:
There. There’s your darned article for the day!
Seriously, yesterday’s article was really messed up. Fortunately, the kind folks at Reddit chimed in and were eager to help! The folks at Linux.org are usually good at catching the mistakes, of which there were many, but probably didn’t as the article is one from the old site and probably only skimmed it if they read it at all.
This leads me to think that I’m eventually going to have issues with getting an article up every other day. I’m still going to try, and I’ve done so since the start, but it’s pretty likely that I’ll eventually miss a day. I’ll try to take steps to not let that happen, but the real world is a fickle mistress.
Thanks for reading! If you want to help, or if the site has helped you, you can donate, register to help, write an article, or buy inexpensive hosting to start your own site. If you scroll down, you can sign up for the newsletter, vote for the article, and comment.
Test…
sudo apt update
Test again…
uptime
You can also check syslog for the following lines to see when your system last booted up, they may differ a bit depending on what distribution and log system your distribution uses.
Aug 9 19:26:07 raven kernel: Command line: BOOT_IMAGE=(hd3,gpt2)/vmlinuz-4.18.0-305.10.2.el8_4.x86_64 root=/dev/mapper/vg0-root ro crashkernel=auto resume=/dev/mapper/vg0-swap rd.lvm.lv=vg0/root rd.lvm.lv=vg0/swap rhgb quiet systemd.unified_cgroup_hierarchy=1
Aug 9 19:26:16 raven rsyslogd[4012]: [origin software="rsyslogd" swVersion="8.1911.0-7.el8_4.2" x-pid="4012" x-info="https://www.rsyslog.com"] start