什么是DMI?DMI (Desktop Management Interface, DMI)的主要组成部分是Management InformationFormat (MIF)数据库,这个数据库包括了所有有关电脑系统和配件的信息。
不需要记下面的命令, 通常打印所有硬件信息, 然后根据需要过滤。
1.常用用法如下(需要root权限):
[rt@rangotec.com ~]# dmidecode                       # 打印所有硬件信息
[rt@rangotec.com ~]# dmidecode -q                    # 打印所有硬件信息,比较简洁
[rt@rangotec.com ~]# dmidecode -h                    # 获取帮助
[rt@rangotec.com ~]# dmidecode | grep 'Product Name' # 以过滤的方式来查看指定的硬件信息
[rt@rangotec.com ~]# dmidecode --type bios         # 查看BIOS相关的硬件信息
[rt@rangotec.com ~]# dmidecode --type system       # 查看系统相关的硬件信息
[rt@rangotec.com ~]# dmidecode --type baseboard    # 查看主板相关的硬件信息
[rt@rangotec.com ~]# dmidecode --type chassis      # 查看机箱相关的硬件信息
[rt@rangotec.com ~]# dmidecode --type processor    # 查看处理器相关的硬件信息
[rt@rangotec.com ~]# dmidecode --type memory       # 查看内存相关的硬件信息
2.查看具体细项信息(以system为例,需root用户)
[rt@rangotec.com ~]# dmidecode -t 1              #查看system基本信息,-t等价于--type
[rt@rangotec.com ~]# dmidecode -t 15             #查看system Event信息
[rt@rangotec.com ~]# dmidecode -t 23             #查看system Reset信息
[rt@rangotec.com ~]# dmidecode -t 32             #查看system Boot信息
[rt@rangotec.com ~]# dmidecode -t 1,15,23,32 #查看system所有信息,等价于dmidecode -t system
$ lspci -tv           # 树状查看
$ lspci -n -vvv
如: 查看网卡型号
$ lspci | grep Ethernet
00:19.0 Ethernet controller: Intel Corporation 82567V-2 Gigabit Network Connection
yxh@rangotec.com:~$ ls -l /sys/block/sd* 
lrwxrwxrwx 1 root root 0 Oct 28 08:57 /sys/block/sda -> ../devices/pci0000:00/0000:00:1f.2/ata1/host0/target0:0:0/0:0:0:0/block/sda 
lrwxrwxrwx 1 root root 0 Oct 28 08:57 /sys/block/sdb -> ../devices/pci0000:00/0000:00:1f.2/ata2/host1/target1:0:0/1:0:0:0/block/sdb 
lrwxrwxrwx 1 root root 0 Oct 28 08:57 /sys/block/sdc -> ../devices/pci0000:00/0000:00:1f.2/ata5/host4/target4:0:0/4:0:0:0/block/sdc
sudo dmidecode -t processor
sudo dmidecode -t memory
# 查看内存插槽数
dmidecode | grep -P -A5 "Memory\s+Device" | grep Size | grep -v Range
# 查看最大容量:
dmidecode | grep -P 'Maximum\s+Capacity'
# 查看内存频率信息
yxh@yxhserver:~$ sudo lshw | grep -A15 "*-memory" | grep clock
clock: 1600MHz (0.6ns)
yxh@yxhserver:~$ sudo dmidecode -t memory | grep Speed
Speed: 1600 MT/s
Configured Memory Speed: 1600 MT/s
Speed: 1600 MT/s
Configured Memory Speed: 1600 MT/s
lsb_release -a         # 查看发行版本信息
uname -a               # 查看内核/操作系统/CPU信息
head -n 1 /etc/issue   # 查看操作系统版本
cat /proc/cpuinfo      # 查看CPU信息
hostname               # 查看计算机名
lsmod                  # 列出加载的内核模块
env                     # 查看环境变量
free -m                     # 查看内存使用量和交换区使用量
df -hT                      # 查看各分区使用情况 , 大写T参数可以列车分区的格式,如 ext4
du -sh <目录名>              # 查看指定目录的大小
grep MemTotal /proc/meminfo # 查看内存总量
grep MemFree /proc/meminfo  # 查看空闲内存量
uptime                      # 查看系统运行时间、用户数、负载
cat /proc/loadavg    # 查看系统负载
mount | column -t         # 查看挂接的分区状态
fdisk -l                  # 查看所有分区
swapon -s                 # 查看所有交换分区
df -hT                    # 查看各分区使用情况 , 大写T参数可以列车分区的格式,如 ext4
hdparm -i /dev/hda        # 查看磁盘参数(仅适用于IDE设备)
dmesg | grep IDE    # 查看启动时IDE设备检测状况
ifconfig        # 查看所有网络接口的属性
iptables -L     # 查看防火墙设置
route -n        # 查看路由表
netstat -lntp   # 查看所有监听端口
netstat -antp   # 查看所有已经建立的连接
netstat -s # 查看网络统计信息
ps -ef # 查看所有进程
top    # 实时显示进程状态
w              # 查看活动用户
id <用户名>     # 查看指定用户信息
last           # 查看用户登录日志
cut -d: -f1 /etc/passwd   # 查看系统所有用户
cut -d: -f1 /etc/group    # 查看系统所有组
crontab -l                # 查看当前用户的计划任务
chkconfig --list           # 列出所有系统服务
chkconfig --list | grep on # 列出所有启动的系统服务