51Testing软件测试论坛

 找回密码
 (注-册)加入51Testing

QQ登录

只需一步,快速开始

微信登录,快人一步

查看: 3228|回复: 0

查看 Linux 版本和内核的方法

[复制链接]
  • TA的每日心情
    无聊
    昨天 09:28
  • 签到天数: 385 天

    连续签到: 4 天

    [LV.9]测试副司令

    发表于 2019-1-7 17:00:53 | 显示全部楼层 |阅读模式
    1. uname 命令

    uname(unix name) 是一个打印系统信息的工具,包括内核名称、版本号、系统详细信息以及所运行的操作系统等等。

    1. root@test-01 ~ >> uname -a
    2. Linux test-01 3.10.0-693.21.1.el7.x86_64 #1 SMP Wed Mar 7 19:03:37 UTC 2018 x86_64 x86_64 x86_64 GNU/Linux
    复制代码
    2. /proc/version 文件

    这个文件记录了 Linux 内核的版本、用于编译内核的 gcc 的版本、内核编译的时间,以及内核编译者的用户名。

    1. root@test-01 ~ >> cat /proc/version
    2. Linux version 3.10.0-693.21.1.el7.x86_64 (builder@kbuilder.dev.centos.org) (gcc version 4.8.5 20150623 (Red Hat 4.8.5-16) (GCC) ) #1 SMP Wed Mar 7 19:03:37 UTC 2018
    复制代码
    3. RPM 命令

    RPM(红帽包管理器 [ RedHat Package Manager ])是在 CentOS、Oracle Linux、Fedora 这些基于 RedHat 的操作系统上的一个强大的命令行包管理工具,同样也可以帮助我们查看系统的版本信息。

    1. root@test-01 ~ >> rpm -q kernel
    2. kernel-3.10.0-514.el7.x86_64
    3. kernel-3.10.0-693.21.1.el7.x86_64
    复制代码
    4. /boot/ 文件夹

    /boot 文件夹包含所有引导相关的信息文件和文件夹,例如 grub.conf,vmlinuz image aka kernel 等。

    1. root@test-01 ~ >> ll /boot/ | grep vmlinuz
    2. -rwxr-xr-x. 1 root root 5.2M 11月 23 2016 vmlinuz-3.10.0-514.el7.x86_64
    3. -rwxr-xr-x. 1 root root 5.7M 3月   8 03:16 vmlinuz-3.10.0-693.21.1.el7.x86_64
    复制代码
    5. dmesg 命令

    dmesg(展示信息 [ display message ] 或驱动程序信息 [ driver message ])是大多数类 Unix 操作系统上的一个命令,用于打印内核的消息缓冲区的信息。

    1. root@test-01 ~ >> dmesg | grep Linux
    2. [    0.000000] Linux version 3.10.0-693.21.1.el7.x86_64 (builder@kbuilder.dev.centos.org) (gcc version 4.8.5 20150623 (Red Hat 4.8.5-16) (GCC) ) #1 SMP Wed Mar 7 19:03:37 UTC 2018
    3. [    2.644215] Linux agpgart interface v0.103
    4. [    2.658447] usb usb1: Manufacturer: Linux 3.10.0-693.21.1.el7.x86_64 ehci_hcd
    5. [    2.662139] usb usb2: Manufacturer: Linux 3.10.0-693.21.1.el7.x86_64 uhci_hcd
    复制代码
    5. Yum/Dnf 命令

    Yum(Yellowdog 更新器修改版 [ Yellowdog Updater Modified ])是 Linux 操作系统上的一个包管理工具,而 yum 命令被用于一些基于 RedHat 的 Linux 发行版上安装、更新、查找、删除软件包。

    1. root@test-01 ~ >> yum info kernel
    2. Installed Packages
    3. Name        : kernel
    4. Arch        : x86_64
    5. Version     : 3.10.0
    6. Release     : 514.el7
    7. Size        : 148 M
    8. Repo        : installed
    9. From repo   : anaconda
    10. Summary     : The Linux kernel
    11. URL         : http://www.kernel.org/
    12. License     : GPLv2
    13. Description : The kernel package contains the Linux kernel (vmlinuz), the core of any
    14.             : Linux operating system.  The kernel handles the basic functions
    15.             : of the operating system: memory allocation, process allocation, device
    16.             : input and output, etc.

    17. Name        : kernel
    18. Arch        : x86_64
    19. Version     : 3.10.0
    20. Release     : 693.21.1.el7
    21. Size        : 60 M
    22. Repo        : installed
    23. From repo   : updates
    24. Summary     : The Linux kernel
    25. URL         : http://www.kernel.org/
    26. License     : GPLv2
    27. Description : The kernel package contains the Linux kernel (vmlinuz), the core of any
    28.             : Linux operating system.  The kernel handles the basic functions
    29.             : of the operating system: memory allocation, process allocation, device
    30.             : input and output, etc.
    31. root@test-01 ~ >> dnf info kernel
    32. Installed Packages
    33. Name        : kernel
    34. Arch        : x86_64
    35. Epoch       : 0
    36. Version     : 3.10.0
    37. Release     : 514.el7
    38. Size        : 148 M
    39. Repo        : @System
    40. Summary     : The Linux kernel
    41. URL         : http://www.kernel.org/
    42. License     : GPLv2
    43. Description : The kernel package contains the Linux kernel (vmlinuz), the core of any
    44.             : Linux operating system.  The kernel handles the basic functions
    45.             : of the operating system: memory allocation, process allocation, device
    46.             : input and output, etc.

    47. Name        : kernel
    48. Arch        : x86_64
    49. Epoch       : 0
    50. Version     : 3.10.0
    51. Release     : 693.21.1.el7
    52. Size        : 60 M
    53. Repo        : @System
    54. Summary     : The Linux kernel
    55. URL         : http://www.kernel.org/
    56. License     : GPLv2
    57. Description : The kernel package contains the Linux kernel (vmlinuz), the core of any
    58.             : Linux operating system.  The kernel handles the basic functions
    59.             : of the operating system: memory allocation, process allocation, device
    60.             : input and output, etc.

    61. Available Packages
    62. Name        : kernel-debug
    63. Arch        : x86_64
    64. Epoch       : 0
    65. Version     : 3.10.0
    66. Release     : 693.21.1.el7
    67. Size        : 45 M
    68. Repo        : updates
    69. Summary     : The Linux kernel compiled with extra debugging enabled
    70. URL         : http://www.kernel.org/
    71. License     : GPLv2
    72. Description : The kernel package contains the Linux kernel (vmlinuz), the core of any
    73.             : Linux operating system.  The kernel handles the basic functions
    74.             : of the operating system:  memory allocation, process allocation, device
    75.             : input and output, etc.
    76.             :
    77.             : This variant of the kernel has numerous debugging options enabled.
    78.             : It should only be installed when trying to gather additional information
    79.             : on kernel bugs, as some of these options impact performance noticably.
    复制代码
    6. lsb_release 命令(此命令适用于所有的 Linux 发行版本)

    LSB(Linux 标准库 [ Linux Standard Base ])能够打印发行版的具体信息,包括发行版名称、版本号、代号等。

    如没有此命令可运行 yum install redhat-lsb-core 安装

    1. root@test-01 ~ >> lsb_release -a
    2. LSB Version:        :core-4.1-amd64:core-4.1-noarch
    3. Distributor ID:        CentOS
    4. Description:        CentOS Linux release 7.4.1708 (Core)
    5. Release:        7.4.1708
    6. Codename:        Core
    复制代码
    7. /etc/*release 文件

    release 文件通常被视为操作系统的标识。在 /etc 目录下放置了很多记录着发行版各种信息的文件,每个发行版都各自有一套这样记录着相关信息的文件。

    1. root@test-01 ~ >> ll /etc/*release
    2. -rw-r--r--. 1 root root  38 Aug 30  2017 /etc/centos-release
    3. -rw-r--r--. 1 root root 393 Aug 30  2017 /etc/os-release
    4. lrwxrwxrwx. 1 root root  14 Mar 23 12:45 /etc/redhat-release -> centos-release
    5. lrwxrwxrwx. 1 root root  14 Mar 23 12:45 /etc/system-release -> centos-release

    6. root@test-01 ~ >> cat /etc/os-release
    7. NAME="CentOS Linux"
    8. VERSION="7 (Core)"
    9. ID="centos"
    10. ID_LIKE="rhel fedora"
    11. VERSION_ID="7"
    12. PRETTY_NAME="CentOS Linux 7 (Core)"
    13. ANSI_COLOR="0;31"
    14. CPE_NAME="cpe:/o:centos:centos:7"
    15. HOME_URL="https://www.centos.org/"
    16. BUG_REPORT_URL="https://bugs.centos.org/"

    17. CENTOS_MANTISBT_PROJECT="CentOS-7"
    18. CENTOS_MANTISBT_PROJECT_VERSION="7"
    19. REDHAT_SUPPORT_PRODUCT="centos"
    20. REDHAT_SUPPORT_PRODUCT_VERSION="7"

    21. root@test-01 ~ >> cat /etc/centos-release
    22. CentOS Linux release 7.4.1708 (Core)
    复制代码
    8. /etc/issue | /etc/issue.net 文件(此命令适用于所有的 Linux 发行版本)
    1. root@test-01 ~ >> cat /etc/issue
    2. CentOS release 6.6 (Final)
    3. Kernel \r on an \m

    4. root@test-01 ~ >> cat /etc/issue.net
    5. CentOS release 6.6 (Final)
    6. Kernel \r on an \m
    复制代码



    回复

    使用道具 举报

    本版积分规则

    关闭

    站长推荐上一条 /1 下一条

    小黑屋|手机版|Archiver|51Testing软件测试网 ( 沪ICP备05003035号 关于我们

    GMT+8, 2024-3-29 23:42 , Processed in 0.065285 second(s), 24 queries .

    Powered by Discuz! X3.2

    © 2001-2024 Comsenz Inc.

    快速回复 返回顶部 返回列表