如何查看linux CentOS和Red Hat安装时间

时间:2019-08-20 17:58:14  来源:igfitidea点击:

下面的步骤适用于基于Red Hat的linux发行版。

找出basesystem rpm安装包

[root@theitroad ~]# rpm -qa|grep basesystem
basesystem-10.0-7.el7.centos.noarch

查看basesystem的信息

其中包含了“安装日期” Install Date

[root@theitroad ~]# rpm -qi basesystem-10.0-7.el7.centos.noarch
Name        : basesystem
Version     : 10.0
Release     : 7.el7.centos
Architecture: noarch
Install Date: Wed 30 Sep 2017 01:39:43 PM EDT
Group       : System Environment/Base
Size        : 0
License     : Public Domain
Signature   : RSA/SHA256, Thu 03 Jul 2014 08:46:57 PM EDT, Key ID 24c6a8a7f4a80eb5
Source RPM  : basesystem-10.0-7.el7.centos.src.rpm
Build Date  : Fri 27 Jun 2014 06:37:10 AM EDT
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.

另外一种方法-查看Linux操作系统(CentOS和Red Hat)的安装日期

Linux操作系统安装在/root分区中。
所以我们可以查看分区的创建时间。

执行 “df-Th”获取/安装位置的信息

Hyman@theitroad:/tmp$ df -h
Filesystem      Size  Used Avail Use% Mounted on
/dev/sda5        28G   25G  1.6G  95% /
udev            2.0G  4.0K  2.0G   1% /dev
tmpfs           796M  980K  795M   1% /run
none            5.0M     0  5.0M   0% /run/lock
none            2.0G   12M  2.0G   1% /run/shm
none            100M   56K  100M   1% /run/user
cgroup          2.0G     0  2.0G   0% /sys/fs/cgroup
/dev/sda7       9.2G  8.9G     0 100% /partition7
/dev/sda8        46G   41G  3.1G  93% /partition8
/dev/sda9        74G   40G   31G  57% /partition9
Hyman@theitroad:/tmp$

根目录挂载在 sda5中。

使用命令tune2fs 查看文件系统创建时间

root@theitroad:~# tune2fs -l /dev/sda5 |grep  'Filesystem created'
Filesystem created:       Wed 30 Sep 2017 01:39:43
root@theitroad:~#