查看 Linux 系统架构的命令

整理一些查看 Linux 系统架构的命令汇总。

查看内核版本

  • cat /proc/version

    $ cat /proc/version
    Linux version 5.13.0-30-generic (buildd@lcy02-amd64-003) (gcc (Ubuntu 9.3.0-17ubuntu1~20.04) 9.3.0, GNU ld (GNU Binutils for Ubuntu) 2.34) #33~20.04.1-Ubuntu SMP Mon Feb 7 14:25:10 UTC 2022
  • uname -a

    $ uname -a
    Linux hih-l-9286 5.13.0-30-generic #33~20.04.1-Ubuntu SMP Mon Feb 7 14:25:10 UTC 2022 x86_64 x86_64 x86_64 GNU/Linux
  • uname -r

    $ uname -r
    5.13.0-30-generic

查看 Linux 版本信息

  • lsb_release -a

    $ lsb_release -a
    No LSB modules are available.
    Distributor ID:	Ubuntu
    Description:	Ubuntu 20.04.4 LTS
    Release:	20.04
    Codename:	focal
  • cat /etc/issue

    $ cat /etc/issue
    Ubuntu 20.04.4 LTS \n \l

查看 linux 是 64 为还是 32 位

  • getconf LONG_BIT

    $ getconf LONG_BIT
    64
  • file /bin/ls

    $ file /bin/ls
    /bin/ls: ELF 64-bit LSB shared object, x86-64, version 1 (SYSV), dynamically linked, interpreter /lib64/ld-linux-x86-64.so.2, BuildID[sha1]=2f15ad836be3339dec0e2e6a3c637e08e48aacbd, for GNU/Linux 3.2.0, stripped

查看系统的架构

  • dpkg --print-architecture

    $ dpkg --print-architecture
    amd64
  • arch

    $ arch
    x86_64
  • file /lib/systemd/systemd

    $ file /lib/systemd/systemd
    /lib/systemd/systemd: ELF 64-bit LSB shared object, x86-64, version 1 (SYSV), dynamically linked, interpreter /lib64/ld-linux-x86-64.so.2, BuildID[sha1]=52d683fd53e75da4dcfe607c8080cdf2d8ae1ce5, for GNU/Linux 3.2.0, stripped

查看 Mint 系统对应的 Ubuntu 系统

使用 cat /etc/os-release 命令也可以获取到 Ubuntu 代号:

$ cat /etc/os-release 
NAME="Ubuntu"
VERSION="20.04.4 LTS (Focal Fossa)"
ID=ubuntu
ID_LIKE=debian
PRETTY_NAME="Ubuntu 20.04.4 LTS"
VERSION_ID="20.04"
HOME_URL="https://www.ubuntu.com/"
SUPPORT_URL="https://help.ubuntu.com/"
BUG_REPORT_URL="https://bugs.launchpad.net/ubuntu/"
PRIVACY_POLICY_URL="https://www.ubuntu.com/legal/terms-and-policies/privacy-policy"
VERSION_CODENAME=focal
UBUNTU_CODENAME=focal