系统信息与硬件
系统与内核
uname -a # 内核信息(版本、架构)
uname -r # 内核版本号
cat /etc/os-release # 发行版信息
hostnamectl # 主机名 + 系统版本
lsb_release -a # 发行版详情(部分系统需安装 lsb-release)
date # 当前时间
date -s "2024-01-01 00:00" # 设置时间(需 root)
timedatectl # 系统时间与时区
timedatectl list-timezones | grep Shanghai
timedatectl set-timezone Asia/Shanghai # 设置时区
uptime # 运行时长与负载
CPU
lscpu # CPU 架构、核数、型号
cat /proc/cpuinfo | grep "model name" | head -1 # CPU 型号
nproc # 逻辑核数
mpstat -P ALL 1 # 每核使用率(sysstat)
内存
free -h # 内存 + swap 使用
free -m # 以 MB 显示
cat /proc/meminfo # 详细内存信息
注意
free中available才是真正可用内存,不要只看free列(缓存会被自动回收)。
磁盘与块设备
lsblk # 磁盘与分区结构
df -h # 各挂载点容量
blkid # 分区 UUID / 文件系统类型(详见磁盘篇)
smartctl -a /dev/sda # 硬盘健康检测(SMART,需安装 smartmontools)
外设与硬件
lspci # PCI 设备(显卡、网卡等)
lspci | grep -i vga # 显卡信息
lsusb # USB 设备
lsusb -t # USB 树状结构
lshw # 完整硬件清单(需 root,需安装 lshw)
lshw -short # 精简输出
dmidecode -t memory # 内存条信息(需 root)
dmidecode -t system # 主板/厂商信息
温度与风扇(需 lm-sensors)
sensors # 温度、风扇转速
关机 / 重启
shutdown -h now # 立即关机
shutdown -r now # 立即重启
shutdown -h +10 # 10 分钟后关机
reboot # 重启
poweroff # 关机
系统限制
ulimit -a # 查看所有资源限制
ulimit -n # 查看文件描述符上限
ulimit -n 65535 # 临时提高上限
sysctl vm.max_map_count # 查看内核参数
sysctl -w vm.max_map_count=262144 # 临时修改内核参数
sysctl -p # 从 /etc/sysctl.conf 加载生效
getconf _NPROCESSORS_ONLN # 在线核数
getconf LONG_BIT # 系统位数(32/64)
生产环境报 "too many open files" 时,调大
ulimit -n并写入/etc/security/limits.conf。