I am always curious to know small interesting things about Linux. Today, a question popped out in my mind. How long have I been using my Arch Linux OS? I have no idea when I installed my Arch Linux. It is working very well since it was installed. I am sure it was an year ago. But, I don't know the exact day. Have you ever wondered how long have you been using your Linux OS without a reinstall? Read on to find exact installation date and time of your Linux OS.
Find Exact Linux Installation Date And Time
There are a few ways to find Linux operating system's installation date and time. Here I have given all possible ways.
1. Using Stat Command
The stat
command displays file or file system status in Linux and Unix-like systems. Stat command is part of GNU coreutils package, so you don't need to install it.
To check Linux OS installation date with stat
command, simply run:
$ stat / | grep "Birth" | sed 's/Birth: //g' | cut -b 2-11 2021-05-20
You can also use awk
with stat
command to display Linux installation date as well:
$ stat / | awk '/Birth: /{print $2}' 2021-05-20
There is no need to use grep
or sed
or awk
command. Stat command also has a built-in flag to check exact Linux installation date and time.
$ stat -c %w / 2021-05-20 17:31:10.000000000 +0530
As you can see in the above outputs, the installation date and time of my Fedora Linux desktop is May 20, 2021.
2. Analyze Pacman Logs On Arch Linux
If you use Arch Linux and its derivatives like EndeavourOS and Manjaro Linux, you can easily find how long have you been using it without a reinstall by analyzing the pacman logs as shown below.
$ head -n1 /var/log/pacman.log
Sample output from my Arch Linux system:
[2016-05-05 13:10] [PACMAN] Running 'pacman -r /mnt -Sy --print-format=%s --cachedir=/mnt/var/cache/pacman/pkg --noconfirm base sudo grub wireless_tools wpa_supplicant wpa_actiond netctl dialog os-prober'
As you see in the above, I am still using my first installation from May, 05 2016.
Even though Arch Linux is rolling release model, I have never had to reinstall Arch Linux. It works perfectly well without breaking anything. I have 3 Arch Linux systems (One host and two vms) over the years, and I've never had to "reinstall" even once. And, I am sure I am not going to reinstall it anytime soon.
3. Check Syslog Entries On Debian-based systems
On Debian, Ubuntu and other DEB-based systems, look in the "syslog"
entries to get Linux OS installation date and time
$ sudo head -n1 /var/log/installer/syslog
Sample output:
Jul 2 10:29:10 ubuntu systemd[1]: Starting Flush Journal to Persistent Storage...
What If the logs are deleted already? No problem. You still can find out the installation time of your Linux OS by verifying filesystem creation date as shown in the following section.
4. Check Filesystem Creation Date
As stated, sometimes, you might have deleted the logs (or enabled log rotation). In such cases, you can find the installation date like below.
Switch to root
user:
$ sudo su
Now, run any one of the following commands as root
user.
# fs=$(df / | tail -1 | cut -f1 -d' ') && tune2fs -l $fs | grep 'Filesystem created'
Or,
# tune2fs -l /dev/sda1 | grep 'Filesystem created:'
Or,
# dumpe2fs /dev/sda1 | grep 'Filesystem created:'
Replace /dev/sda1
with correct hdd drive partition.
It will display when the file system was originally created.
Sample output:
Filesystem created: Thu May 20 17:31:06 2021
These commands will work on all Linux distributions that supports ext4
filesystems.
5. Using Basesystem
Basesystem defines the components of a basic Fedora system (for example, the package installation order to use during bootstrapping). Basesystem should be in every installation of a system, and it should never be removed.
On Fedora, RHEL and its clones such as CentOS, AlmaLinux, and Rocky Linux, you can find Linux install date using command:
$ sudo rpm -qi basesystem
Sample output:
Name : basesystem Version : 11 Release : 11.fc34 Architecture: noarch Install Date: Friday 23 April 2021 04:26:31 PM Group : Unspecified Size : 0 License : Public Domain Signature : RSA/SHA256, Tuesday 26 January 2021 07:17:35 AM, Key ID 1161ae6945719a39 Source RPM : basesystem-11-11.fc34.src.rpm Build Date : Tuesday 26 January 2021 07:15:29 AM Build Host : buildhw-x86-04.iad2.fedoraproject.org Packager : Fedora Project Vendor : Fedora Project Bug URL : https://bugz.fedoraproject.org/basesystem Summary : The skeleton package which defines a simple Fedora system Description : Basesystem defines the components of a basic Fedora system (for example, the package installation order to use during bootstrapping). Basesystem should be in every installation of a system, and it should never be removed.
Or, to display the installation date only, run this:
$ sudo rpm -qi basesystem | grep Install Install Date: Friday 23 April 2021 04:26:31 PM
Or use this command:
$ sudo rpm -q basesystem --qf '%{installtime:date}\n' Friday 23 April 2021 04:26:31 PM
6. Using Install-date Script
There is a script named install-date, which is used to determine install date of an installation of Linux, using various methods. It currently works only on Arch Linux and Gentoo systems.
Go to the install-date repository on GitHub and download the script using command:
$ wget -O installdate.sh https://raw.githubusercontent.com/alicela1n/install-date/main/install-date
Watch out for the -O
option. It must be UPPERCASE.
Make the script executable:
$ chmod +x installdate.sh
Now run the script to determine the date and time of Arch Linux installation:
$ ./installdate.sh 2021-06-01
Conclusion
In this guide, I have listed 6 methods to find the exact installation date and time of a Linux distribution. Knowing your Linux installation date and time may not directly provide any benefits to you. However, you can use this information to find how long you're running a Linux distribution without reinstalling.
Featured Image Credit - Pixabay
9 comments
I found that on my Fedora installation the basesystem package was updated between Fedora 25 and 26 so that might not be a reliable way to determine the original installation time.
There are much better ways. The simplest for most installations is to check where / is mounted and then do
dumpe2fs /dev/whatever |grep created
That will give you the date the filesystem itself was created
Wow, my current Manjaro install is almost 2 years old. More then I remembered. System still works great!
if i want to change instalation time 5 years back then how will i do?
Is it possible tô change The date?
not reliable, it shows all the same date in rpm on may Azure VMs… probably Azure installes all from the same image
On Ubuntu Systems you could use the date of “/var/log/installer/syslog”
Yes Super
Nice, i was trying to remember when I installed arch. Now I remember: in 2016 i installed the system on a 2GB thumb drive so i could play minecraft on a windows PC with crappy drivers ;P once i realized how cool it was I switched from debian to arch. I didn’t think to check the date on the filesystem X)