这里编写和总结了常用的查询服务器硬件信息的命令和安装方法:

  1. CPU信息:
  • 查询CPU型号和频率:
cat /proc/cpuinfo | grep "model name" | uniq
cat /proc/cpuinfo | grep "cpu MHz" | uniq
  • 查询CPU厂商信息:
cat /proc/cpuinfo | grep "vendor_id" | uniq
  1. 内存信息:
  • 查询内存总大小:
free -h | grep "Mem" | awk '{print $2}'
  • 查询内存频率:
sudo dmidecode --type memory | grep "Speed" | uniq
  • 查询缓存大小:
cat /proc/cpuinfo | grep "cache size" | uniq
  1. 磁盘信息:
  • 查询磁盘总大小:
df -h --total | grep "total" | awk '{print $2}'
  • 查询磁盘类型:
sudo parted -l | grep "Disk" | awk '{print $3}'
  • 查询磁盘阵列和RAID信息:
sudo mdadm --detail /dev/md0  # 将 `/dev/md0` 替换为你要查询的RAID设备
  1. 网络信息:
  • 查询网卡型号和速度:
lspci | grep -i network
ethtool eth0  # 将 `eth0` 替换为你要查询的网卡设备
  • 查询网络带宽:
speedtest-cli

对于需要安装的工具,以下是一些典型的安装方法:

  • 对于Debian/Ubuntu系统,使用apt-get进行安装:
sudo apt-get install lshw smartmontools ethtool speedtest-cli
  • 对于CentOS/RHEL系统,使用yum进行安装:
sudo yum install lshw smartmontools ethtool epel-release
sudo yum install speedtest-cli
  • 对于其他Linux发行版,可以使用相应的软件包管理器来安装所需的工具。

使用上述命令和安装方法,你可以查询到CPU型号、频率、厂商,内存大小、缓存大小、内存频率,磁盘总大小、磁盘类型、是否有磁盘阵列、是否做RAID、RAID类型,网络带宽、网卡速度和网卡型号等硬件信息。