Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Select an option

  • Save kurtis318/3451786bc7b2c70cb62ce5276be07efa to your computer and use it in GitHub Desktop.

Select an option

Save kurtis318/3451786bc7b2c70cb62ce5276be07efa to your computer and use it in GitHub Desktop.
How to determine Linux OS installation date

Issue:

How to determine when a Linux OS was installed?

Solution 1: Any Linux OS

REF: https://www.ostechnix.com/find-exact-installation-date-time-linux-os/

Here is a command that takes into account xfs file systems. tune2fs only works with ext2/ext3/ext4 file systems.

fs=$(df / | tail -1 | cut -f1 -d' ') && \
  tune2fs -l $fs 2>/dev/null | grep created \
  || stat /dev/sr0|awk '/^Access:/{print $2" "substr($3,1,8);}'

Solution 2: RPM based Linux OS

Check the date when basesystem rpm was installed.

$ rpm -qi basesystem
Name        : basesystem
Version     : 10.0
Release     : 7.el7.centos
Architecture: noarch
Install Date: Wed 02 Jan 2019 11:31:17 PM CST
Group       : System Environment/Base
Size        : 0
License     : Public Domain
Signature   : RSA/SHA256, Thu 03 Jul 2014 07:46:57 PM CDT, Key ID 24c6a8a7f4a80eb5
Source RPM  : basesystem-10.0-7.el7.centos.src.rpm
Build Date  : Fri 27 Jun 2014 05:37:10 AM CDT
Build Host  : worker1.bsys.centos.org
Relocations : (not relocatable)
Packager    : CentOS BuildSystem <http://bugs.centos.org>
Vendor      : CentOS
Summary     : The skeleton package which defines a simple CentOS Linux system
Description :
Basesystem defines the components of a basic CentOS Linux
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.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment