Loading...
X

How to find out when Linux was installed

This article will look at several ways to find out the date of installation of the Linux operating system. But let's start by thinking about what is considered the date of installation of the OS?

What is considered the date of installation of Linux

It would seem that the question and the answer to it are quite simple – the installation date is the day when the operating system files were copied from the installation disk or flash drive.

But if a major OS update was made, that is, a transition between major versions, can this be considered the date of installation of the current OS? This update can be done either by updating packages or using the installation media (for example, Tails is updated only this way).

If we take the age of the oldest file in the OS for the installation date, then you may encounter the following situation: the user's home folder, created and used much earlier with other (previous versions) of the OS, is mounted on the freshly installed system, - whether to consider the installation date according to the oldest part of the OS (home user folder) or by the date the files of the new OS were copied?

It can be assumed that the key element is the root file system and you need to look at the date of its creation. In general, usually many agree that it is the creation date of the root file system that should be considered the date of the OS installation, but the following situations are possible:

  • the file system was changed or converted after the OS was installed
  • the cloned file system may have been migrated to another disk

In general, there are nuances that you need to remember, but they do not apply to most users.

1. Date of creation of the file system

To find out the creation date of the file system, run the command:

tune2fs -l `df / | grep '/' | awk '{ print $1 }'` | grep 'Filesystem created:'

Output example:

Filesystem created:       Wed Aug  1 19:40:20 2018

That is, the operating system was installed on August 1, 2018.

Another command that will show the creation date of the file system in Linux:

dumpe2fs $(mount | grep 'on \/ ' | awk '{print $1}') | grep 'Filesystem created:'

It is also recommended to read the article “How to know when the ext4/ext3/ext2 filesystem was created and when it was last mounted”, in it you will learn how to find out how many times the file system was mounted, how much data was written to it , the date of the last entry and other interesting information.

2. Age of the oldest files in the OS

The most file system and distribution neutral solution is to use the oldest file found with the “ls -lact /etc” command, which checks the metadata of each file at the time of creation. This method is not affected by the touch command or files created by extracting archives (eg tar -p to preserve timestamps).

The creation time of the oldest file on Linux can be found with the following command:

ls -lact --full-time /etc | tail

The results of this method are consistent with previous data – August 1, 2018.

If you only want to get the creation time of the oldest file in /etc:

ls -lact --full-time /etc | awk 'END {print $6,$7,$8}'

 

The following command will display the date and time the first file was created in the usual format:

ls -ctl --time-style +"%H:%M:%S %d.%m.%Y" /etc | awk 'END{print $6, $7}'

3. Age of the root directory

The age of the oldest file (everything is a file) in the root can be viewed by the root itself:

stat / | tail -1


Leave Your Observation

Your email address will not be published. Required fields are marked *