linux 查看系统信息

tim_xiao -
linux 查看系统信息
1:uname
$ uname --help
Usage: uname [OPTION]...
Print certain system information.  With no OPTION, same as -s.

  -a, --all                print all information, in the following order,
                             except omit -p and -i if unknown:
  -s, --kernel-name        print the kernel name
  -n, --nodename           print the network node hostname
  -r, --kernel-release     print the kernel release
  -v, --kernel-version     print the kernel version
  -m, --machine            print the machine hardware name
  -p, --processor          print the processor type or "unknown"
  -i, --hardware-platform  print the hardware platform or "unknown"
  -o, --operating-system   print the operating system
      --help     display this help and exit
      --version  output version information and exit

GNU coreutils online help: <http://www.gnu.org/software/coreutils/>
For complete documentation, run: info coreutils 'uname invocation'

常用

# 显示所有
$ uname -a  
# 硬件平台
$ uname -i  
x86_64
# 内核版本号
$ uname -r
3.10.0-229.el7.x86_64
$ uname -v
#1 SMP Fri Mar 6 11:36:42 UTC 2015
2:/proc/version

系统运行内核版本号以及gcc版本号

$ cat /proc/version 
Linux version 3.10.0-229.el7.x86_64 (builder@kbuilder.dev.centos.org) (gcc version 4.8.2 20140120 (Red Hat 4.8.2-16) (GCC) ) #1 SMP Fri Mar 6 11:36:42 UTC 2015
3:/proc/cpuinfo

cpu 相关信息

$ cat /proc/cpuinfo 
processor    : 0
vendor_id    : GenuineIntel
cpu family    : 6
model        : 94
model name    : Intel(R) Core(TM) i5-6400 CPU @ 2.70GHz
stepping    : 3
cpu MHz        : 2711.952
cache size    : 6144 KB
physical id    : 0
siblings    : 1
core id        : 0
cpu cores    : 1
apicid        : 0
initial apicid    : 0
fpu        : yes
fpu_exception    : yes
cpuid level    : 22
wp        : yes
flags        : fpu vme de pse tsc msr pae mce cx8 apic sep mtrr pge mca cmov pat pse36 clflush mmx fxsr sse sse2 syscall nx rdtscp lm constant_tsc rep_good nopl xtopology nonstop_tsc pni pclmulqdq monitor ssse3 cx16 pcid sse4_1 sse4_2 movbe popcnt aes xsave avx rdrand lahf_lm abm 3dnowprefetch fsgsbase avx2 invpcid rdseed
bogomips    : 5423.90
clflush size    : 64
cache_alignment    : 64
address sizes    : 39 bits physical, 48 bits virtual
power management:

常见命令

# 查看物理cpu个数
$ cat /proc/cpuinfo| grep "physical id" |sort | uniq | wc -l
4
# 查看每个物理cpu的核数
$ cat /proc/cpuinfo| grep "cpu cores"| uniq
cpu cores    : 1
# 查看逻辑cpu个数
$ cat /proc/cpuinfo| grep "processor"| wc -l
4
4: lscpu

Display information about the CPU architecture.

lscpu从sysfs和/proc/cpuinfo收集cpu体系结构信息,命令的输出比较易读

$ lscpu 
Architecture:          x86_64
CPU op-mode(s):        32-bit, 64-bit
Byte Order:            Little Endian
CPU(s):                1
On-line CPU(s) list:   0
Thread(s) per core:    1
Core(s) per socket:    1
Socket(s):             1
NUMA node(s):          1
Vendor ID:             GenuineIntel
CPU family:            6
Model:                 94
Model name:            Intel(R) Core(TM) i5-6400 CPU @ 2.70GHz
Stepping:              3
CPU MHz:               2711.952
BogoMIPS:              5423.90
Hypervisor vendor:     Oracle
Virtualization type:   full
L1d cache:             32K
L1i cache:             32K
L2 cache:              256K
L3 cache:              6144K
NUMA node0 CPU(s):     0
Flags:                 fpu vme de pse tsc msr pae mce cx8 apic sep mtrr pge mca cmov pat pse36 clflush mmx fxsr sse sse2 syscall nx rdtscp lm constant_tsc rep_good nopl xtopology nonstop_tsc pni pclmulqdq monitor ssse3 cx16 pcid sse4_1 sse4_2 movbe popcnt aes xsave avx rdrand lahf_lm abm 3dnowprefetch fsgsbase avx2 invpcid rdseed
5: /proc/meminfo

系统内存使用状况

free和vmstat等命令返回数据均来自该文件

详细介绍 参考这里

6: free

Display amount of free and used memory in the system

$ free -h
              total        used        free      shared  buff/cache   available
Mem:           3.7G        119M        3.3G        8.5M        296M        3.4G
Swap:          2.0G          0B        2.0G
7:/proc/uptime 和 /proc/loadavg

系统运行时间和空间时间 单位s

(空闲时间可能会是运行时间的几倍 因为空闲时间是所有逻辑cpu的空闲时间和)

$cat /proc/uptime 
70642.00 282514.43
$ cat /proc/loadavg 
0.00 0.01 0.05 1/170 15387
8:uptime
$ uptime 
 15:22:35 up 19:41,  1 user,  load average: 0.00, 0.01, 0.05

分别表示

当前时间 15:22:35系统已经运行时间 19:41 19小时41分当前在线用户数 1个用户系统负载 1分钟 5分钟 15分钟平均值9:查看系统发行版/etc/os-release
$ cat /etc/os-release
NAME="CentOS Linux"
VERSION="7 (Core)"
ID="centos"
ID_LIKE="rhel fedora"
VERSION_ID="7"
PRETTY_NAME="CentOS Linux 7 (Core)"
ANSI_COLOR="0;31"
CPE_NAME="cpe:/o:centos:centos:7"
HOME_URL="https://www.centos.org/"
BUG_REPORT_URL="https://bugs.centos.org/"

CENTOS_MANTISBT_PROJECT="CentOS-7"
CENTOS_MANTISBT_PROJECT_VERSION="7"
REDHAT_SUPPORT_PRODUCT="centos"
REDHAT_SUPPORT_PRODUCT_VERSION="7"
lsb_release
$ lsb_release -r
Release:    7.2.1511

该命令默认没有被安装 需要自行安装

/etc/issuehostnamectl
$ hostnamectl
   Static hostname: localhost.localdomain
         Icon name: computer-vm
           Chassis: vm
        Machine ID: 15ef07d6ca494a7f82fec477fa70b7e4
           Boot ID: 1b607797966a487b8b72944f0ce619c2
    Virtualization: vmware
  Operating System: CentOS Linux 7 (Core)
       CPE OS Name: cpe:/o:centos:centos:7
            Kernel: Linux 3.10.0-327.el7.x86_64
      Architecture: x86-64
特别申明:本文内容来源网络,版权归原作者所有,如有侵权请立即与我们联系(cy198701067573@163.com),我们将及时处理。
下一篇: linux之pkill命令

Tags 标签

linuxubuntucentos

扩展阅读

加个好友,技术交流

1628738909466805.jpg