A while back I built my friend a fairly simple custom application for his business. It was just a web front end with a MySQL database and never meant for long term use. However, I just spoke with him and he said it was still running. He also mentioned that the only time he ever touched the server was about 2 years ago when there was a power outage. I was amazed and wondered just how long it has been since I brought the server online. I needed a way to find the date and time of the OS installation (I am just a curious person). If you are also a curious person you are probably wondering how long the server was running? Keep reading to find out how to find the date and time Linux OS was installed, as well as how long my buddies system has been running with zero maintenance or updates.
Use stat Command to Find OS Installation (Birth) Date and Time
You can use the stat command to display important information about files. Here we use the stat command to show us the birth date and time of the root filesystem.
[[email protected] savona]# stat -c %w / 2017-10-15 17:18:29.072261178 -0400
The stat command is part of the GNU Core Utilities package and is pre-installed on just about every Linux system.
Get Linux OS Installation Date and Time with basesystem
This trick only works on Fedora, Red Hat, CentOS etc... The basesystem package stores information about the system. One of these pieces of information is the OS Installation date. Here is an example of how to use the
rpm command to get information from basesystem.
[[email protected] savona]# rpm -qi basesystem | grep "Install Date" Install Date: Sun 15 Oct 2017 05:18:45 PM EDT
Find Linux Installation Date and Time from Anaconda Files
Another option is simply finding when the
anaconda-ks.cfg file was created. This file is automatically created to save your installation settings.
[[email protected] savona]# ls -l /root/anaconda-ks.cfg -rw-------. 1 root root 1507 Oct 15 2017 /root/anaconda-ks.cfg
Using Logs to Find Linux Installation Date and Time
There are also some logs that you can use to find the date. Here we use the stat comand again to see the birth of the anaconda.log file.
[[email protected] savona]# ls -l /var/log/anaconda* total 4208 -rw-------. 1 root root 191556 Oct 15 2017 anaconda.log ...OUTPUT TRUNCATED... [[email protected] savona]# stat /var/log/anaconda/anaconda.log File: ‘/var/log/anaconda/anaconda.log’ ...OUTPUT TRUNCATED... Birth: 2017-10-15 17:18:29.744882572 -0400
Again, the above will only work on Fedora/Red Hat systems because they use the Anaconda installer. However, I am sure whatever Linux distro you use, you will find a similar file.
There are plenty of ways to the find the time and date of your Linux OS installation. We just showed you a few quick ways starting with the most widely available, the stat command. As always please feel free to leave a comment and tell us how you would find it!
BTW, it looks like my friends server was running for a total of 1579 days (just over 4 years) with no updates, patches, or human intervention. Interesting...
Resources and Links
This site uses Akismet to reduce spam. Learn how your comment data is processed.
# stat -c %w /
2019-05-13 14:25:31.000000000 +1200
# rpm -qi basesystem | grep "Install Date"
Install Date: Tue 02 Mar 2021 21:51:50
original filesystem creation date is correct. partition was created and formatted: files system created.
install date is different as it was an on-line upgrade, so users need to be aware that these two may be different. there are still some files with Monday, 13 May 2019 2:40:43 as their creation date.
Join Our Newsletter
- Bash Scripting (17)
- Basic Commands (50)
- Featured (7)
- Just for Fun (5)
- Linux Quick Tips (98)
- Linux Tutorials (60)
- Miscellaneous (15)
- Network Tools (6)
- Reviews (2)
- Security (32)
Leave a Reply