CentOS系统/内核版本收集

本文最后更新于2017年1月25日,已超过 1 年没有更新,如果文章内容失效,还请反馈给我,谢谢!

=Start=

缘由:

学习、总结需要。

正文:

# 直接
$ uname -r
$ cat /etc/centos-release
$ cat /proc/version
$ cat /etc/issue
# 使用 lsb_release 命令
$ lsb_release -a
# 如何安装 lsb_release 命令?
$ sudo yum provides */lsb_release
$ sudo yum install redhat-lsb
# 在 CentOS 7 上还可以使用 hostnamectl 命令
$ hostnamectl
function centos_sys_info() {
    os_kernel=$(rpm --query centos-release)":"$(uname -r)
    echo $os_kernel
}

参考链接:

=END=

声明: 除非注明,ixyzero.com文章均为原创,转载请以链接形式标明本文地址,谢谢!
https://ixyzero.com/blog/archives/3181.html

7 thoughts on “CentOS系统/内核版本收集”

  1. # 如何知道正在运行的Linux版本是多少?
    # https://www.cyberciti.biz/faq/howto-find-out-what-kernel-version-running/
    `
    uname -r
    cat /proc/version
    `
    # 如何知道Linux内核是在什么时候安装的?
    # https://stackoverflow.com/questions/28537387/how-to-check-the-installation-date-of-a-kernel-in-linux
    `rpm -q kernel –last`

    # 如何知道Linux系统是在什么时候安装的?
    # https://unix.stackexchange.com/questions/9971/how-do-i-find-how-long-ago-a-linux-system-was-installed
    `tune2fs -l /dev/sda1 | grep ‘Filesystem created:’ # 具体该是 sda1 还是 vda1 可以通过 df 命令的结果来看
    `

  2. CentOS上查看某特定文件是属于哪个RPM包的?
    `
    Method 1 : using rpm command
    # rpm -q –whatprovides $file_name
    # rpm -qf $file_name

    Method 2 : Using yum command
    # yum whatprovides $file_name

    Method 3 : Using repoquery command (available in the yum-utils package)
    # repoquery –whatprovides ‘*bin/grep’
    `
    https://www.thegeekdiary.com/how-to-find-which-rpm-package-provides-a-specific-file-or-library-in-rhel-centos/

    https://stackoverflow.com/questions/1133495/how-do-i-find-which-rpm-package-supplies-a-file-im-looking-for

  3. Discover to which package a file belongs to
    https://linux-audit.com/determine-file-and-related-package/
    `
    # CentOS, Fedora, RHEL
    rpm -ql package
    rpm -qf /bin/ps –queryformat ‘%{NAME}’
    yum whatprovides /bin/ps
    dnf provides /bin/ps

    # Debian and Ubuntu
    dpkg -S /usr/sbin/atd | awk -F: ‘{print $1}’
    dpkg -L package

    # Gentoo
    equery files
    qlist

    # OpenSUSE
    zypper what-provides /bin/ps
    `

发表评论

电子邮件地址不会被公开。 必填项已用*标注