1.查看主机系统信息
查看系统信息:
[root@CentOS7 ~]# 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'
查看CPU/内存/硬盘详细信息:
[root@CentOS7 ~]# top #监控Linux系统状况,如CPU、内存;q退出
[root@CentOS7 ~]# cat /proc/cpuinfo #查看CPU详细信息
[root@CentOS7 ~]# lscpu #查看CPU信息
[root@CentOS7 ~]# free -m #查看内存占用信息
[root@CentOS7 ~]# df -h #查看硬盘占用率
[root@CentOS7 ~]# lsblk -f #查看磁盘挂载及文件系统类型
实例:脚本实现信息查看
[root@CentOS7 shellscript]# vim systeminfo.sh
#!/bin/bash
#
#**********************************
# Author: wanghonron
# Date: 2021-05-10
# FileName: systeminfo.sh
# Url: http://www.werda.com
# Copyright(C):2021All rights reserved
#**********************************
echo "OS: $(uname)"
echo "OS ver: $(cat /etc/redhat-release | cut -d ' ' -f 2,4)"
echo "HOSTNAME: $(hostname)"
echo "ipv4 addr: $(ip a | grep global | cut -d ' ' -f 6)"
echo "kernel ver: $(uname -a | cut -d ' ' -f 3)"
echo "CPU model: $(cat /proc/cpuinfo | grep name | cut -f2 -d :|uniq)"
echo "mem size: $(free -mh | grep Mem | cut -f12 -d ' ')"
echo "disk size: $(df -h | grep ^/.* | cut -d ' ' -f1,8)"
[root@CentOS7 shellscript]# sh systeminfo.sh
OS: Linux
OS ver: Linux 7.2.1511
HOSTNAME: CentOS7.localdomain
ipv4 addr: 10.0.0.7/8
172.17.0.1/16
kernel ver: 3.10.0-327.el7.x86_64
CPU model: Intel(R) Core(TM) i5-2400 CPU @ 3.10GHz
mem size: 1.8G
disk size: /dev/sda2
/dev/sda5 142G
/dev/sda1 997M