linux主机
hostnamectl -- 可以查看“系统架构”,“发行版本”和“内核版本”等信息
# centos7/ubuntu20.04
[root@192 ~]# hostnamectl -h
hostnamectl [OPTIONS...] COMMAND ...
Query or change system hostname.
-h --help Show this help
--version Show package version
--no-ask-password Do not prompt for password
-H --host=[USER@]HOST Operate on remote host
-M --machine=CONTAINER Operate on local container
--transient Only set transient hostname
--static Only set static hostname
--pretty Only set pretty hostname
Commands:
status Show current hostname settings
set-hostname NAME Set system hostname
set-icon-name NAME Set icon name for host
set-chassis NAME Set chassis type for host
set-deployment NAME Set deployment environment for host
set-location NAME Set location for host
# centos7演示
[root@192 ~]# hostnamectl status
Static hostname: localhost.localdomain
Transient hostname: 192.168.21.131
Icon name: computer-vm
Chassis: vm
Machine ID: 0c9900e6f0874e749114249ca020b0cb
Boot ID: 9c72c086215742f4afa843d39d964884
Virtualization: vmware
Operating System: CentOS Linux 7 (Core)
CPE OS Name: cpe:/o:centos:centos:7
Kernel: Linux 3.10.0-1160.102.1.el7.x86_64
Architecture: x86-64
uname -a -- 查看内核版本
# centos7/ubuntu
[root@192 ~]# uname --help
用法:uname [选项]...
输出一组系统信息。如果不跟随选项,则视为只附加-s 选项。
-a, --all 以如下次序输出所有信息。其中若-p 和
-i 的探测结果不可知则被省略:
-s, --kernel-name 输出内核名称
-n, --nodename 输出网络节点上的主机名
-r, --kernel-release 输出内核发行号
-v, --kernel-version 输出内核版本
-m, --machine 输出主机的硬件架构名称
-p, --processor 输出处理器类型或"unknown"
-i, --hardware-platform 输出硬件平台或"unknown"
-o, --operating-system 输出操作系统名称
--help 显示此帮助信息并退出
--version 显示版本信息并退出
# centos7演示
[root@192 ~]# uname -a
Linux 192.168.21.131 3.10.0-1160.102.1.el7.x86_64 #1 SMP Tue Oct 17 15:42:21 UTC 2023 x86_64 x86_64 x86_64 GNU/Linux
# ubuntu20.04演示
root@ubuntu:~# uname -a
Linux ubuntu 5.4.0-165-generic #182-Ubuntu SMP Mon Oct 2 19:43:28 UTC 2023 x86_64 x86_64 x86_64 GNU/Linux
cat /proc/version -- 查看当前操作系统版本信息
# centos7
[root@192 ~]# cat /proc/version
Linux version 3.10.0-1160.102.1.el7.x86_64 (mockbuild@kbuilder.bsys.centos.org) (gcc version 4.8.5 20150623 (Red Hat 4.8.5-44) (GCC) ) #1 SMP Tue Oct 17 15:42:21 UTC 2023
# ubuntu
root@ubuntu:~# cat /proc/version
Linux version 5.4.0-165-generic (buildd@lcy02-amd64-078) (gcc version 9.4.0 (Ubuntu 9.4.0-1ubuntu1~20.04.2)) #182-Ubuntu SMP Mon Oct 2 19:43:28 UTC 2023
cat /etc/issue ,lsb_release -a(ubuntu)-- 查看系统发行版本
cat /etc/redhat-release(centos)-- 查看系统发行版本
# centos7
[root@192 ~]# cat /etc/redhat-release
CentOS Linux release 7.9.2009 (Core)
# ubuntu 20.04
root@ubuntu:~# cat /etc/issue
Ubuntu 20.04.6 LTS \n \l
root@ubuntu:~# lsb_release -a
No LSB modules are available.
Distributor ID: Ubuntu
Description: Ubuntu 20.04.6 LTS
Release: 20.04
Codename: focal
cat /proc/cpuinfo -- 查看cpu信息
# centos7/ubuntu20.4
cat /proc/cpuinfo
docker容器
Ubuntu/Debian系统:
cat /etc/os-release
CentOS/RHEL系统:
cat /etc/redhat-release
Alpine Linux系统:
cat /etc/alpine-release