Linux服务器配置查看,主要包括CPU、内存、硬盘、网卡等信息

一、查看机器所有硬件信息

1、dmidecode |more

dmidecode以一种可读的方式dump出机器的DMI(Desktop Management Interface)信息。这些信息包括了硬件以及BIOS,既可以得到当前的配置,也可以得到系统支持的最大配置,比如说支持的最大内存数等。

#查看bios信息
# dmidecode -t bios

#查看内存信息
# dmidecode -t memory

#查看更多硬件
#dmidecode -q

2、dmesg |more

二、CPU

1、lscpu

显示CPU架构信息

[oracle@xxx ~]$ lscpu
Architecture:          x86_64
CPU op-mode(s):        32-bit, 64-bit
Byte Order:            Little Endian
CPU(s):                24                 #逻辑处理器核心总数量
On-line CPU(s) list:   0-23
Thread(s) per core:    2                  #每个核心支持线程数量。2表示支持2个线程
Core(s) per socket:    6                  #每个处理器的核心梳理
Socket(s):             2                  #逻辑插槽(路)数量,貌似等于物理CPU个数
NUMA node(s):          1
Vendor ID:             GenuineIntel       #CPU厂商intel
CPU family:            6
Model:                 62
Stepping:              7
CPU MHz:               1200.000
BogoMIPS:              3799.50
Virtualization:        VT-x               #支持虚拟化
L1d cache:             32K
L1i cache:             32K
L2 cache:              256K
L3 cache:              12288K
NUMA node0 CPU(s):     0-23

总处理器核心数量=物理处理器数量*每个处理器的核心数量*每个核心支持的线程数量。即:CPU(s) = Socket(s) * Core(s) * Thread(s)。

[xxx@localhost ~]$ man lscpu
   COLUMNS
       CPU    The logical CPU number of a CPU as used by the Linux kernel.    #逻辑CPU数量
       CORE   The logical core number. A core can contain several CPUs.      #逻辑核心数量
       SOCKET The logical socket number. A socket can contain several cores.   #逻辑插槽(路)数量

2、cat  /proc/cpuinfo

查看CPU详细信息,Linux下CPU相关的参数保存在 /proc/cpuinfo 文件里,内容太多可结合 | more ,less进行查看,还可以grep查看

# 查看物理CPU个数
cat /proc/cpuinfo |grep 'physical id'|sort|uniq|wc -l

# 查看每个物理CPU中core的个数(即核数)

[oracle@xxxx~]$ cat /proc/cpuinfo | grep "cpu cores" | uniq
cpu cores       : 6

# 查看每个物理CPU中线程的个数

[oracle@xxx~]$ cat /proc/cpuinfo | grep "siblings" | uniq
siblings        : 12

# 查看逻辑CPU的个数
[oracle@xxx~]$ cat /proc/cpuinfo| grep "processor"|wc -l
24

# 查看CPU型号
[oracle@xxxx~]$ cat /proc/cpuinfo | grep "model name" |uniq
model name      : Intel(R) Xeon(R) CPU E7-4809 v2 @ 1.90GHz

3、查看CPU的位数

getconf LONG_BIT

[oracle@XXX~]$ getconf LONG_BIT
64

三、内存

1、free

[oracle@xxx~]$ free -m
             total       used       free     shared    buffers     cached
Mem:         16022      15817        204          0         91      10244
-/+ buffers/cache:       5481      10541
Swap:        16383         12      16371
[oracle@xxx~]$ free -g
             total       used       free     shared    buffers     cached
Mem:            15         15          0          0          0         10
-/+ buffers/cache:          5         10
Swap:           15          0         15

2、cat  /proc/meminfo

查询内存详细 信息,可结合grep 关键字 查看相关内容

[oracle@xxx~]$ cat /proc/meminfo
MemTotal:       16407016 kB  
MemFree:          212348 kB
Buffers:           93632 kB
Cached:         10490756 kB
SwapCached:         1168 kB
Active:         11509608 kB
Inactive:        2720652 kB
Active(anon):   10227368 kB
Inactive(anon):  1381716 kB
Active(file):    1282240 kB
Inactive(file):  1338936 kB
Unevictable:           0 kB
Mlocked:               0 kB
SwapTotal:      16777208 kB
SwapFree:       16764424 kB
Dirty:                60 kB
Writeback:             0 kB
AnonPages:       3644800 kB
Mapped:          5932092 kB
Shmem:           7963196 kB
Slab:             337868 kB
SReclaimable:     237832 kB
SUnreclaim:       100036 kB
KernelStack:       11648 kB
PageTables:      1312736 kB
NFS_Unstable:          0 kB
Bounce:                0 kB
WritebackTmp:          0 kB
CommitLimit:    24980716 kB
Committed_AS:   15765032 kB
VmallocTotal:   34359738367 kB
VmallocUsed:      315516 kB
VmallocChunk:   34359369140 kB
HardwareCorrupted:     0 kB
AnonHugePages:    407552 kB
HugePages_Total:       0
HugePages_Free:        0
HugePages_Rsvd:        0
HugePages_Surp:        0
Hugepagesize:       2048 kB
DirectMap4k:        4096 kB
DirectMap2M:     2027520 kB
DirectMap1G:    14680064 kB

3、top

4、查看内存信息(显示插槽个数和每个插槽里内存条的大小)


[root@xxx~]# dmidecode -t memory | grep Size |grep -v  'No Module Installe'
        Size: 8192 MB
        Size: 8192 MB

我的主板有多个槽位,这里过滤了下,显示使用了2个槽位,每个8G。

5、查看内存条厂家


[root@swnode2 ~]# dmidecode -t memory | grep Manufacturer |grep -v 'NO DIMM'
        Manufacturer: Samsung
        Manufacturer: Samsung

四、硬盘

1、lsblk

blk是block的缩写。列出块设备,可显示挂载点(文件系统),显示很直观

[root@xxx~]# lsblk
NAME   MAJ:MIN RM  SIZE RO TYPE MOUNTPOINT
sda      8:0    0  1.8T  0 disk
├─sda1   8:1    0  200M  0 part /boot
├─sda2   8:2    0   16G  0 part [SWAP]
└─sda3   8:3    0  1.8T  0 part /

其中,TYPE=disk表示硬盘。可以看出,硬盘sda 分了3个分区。type 还可以是part(分区)、lvm等

2、fdisk -l

可以看到系统上的磁盘(包括U盘)的分区以及大小相关信息。

[root@xxx~]# fdisk -l
Disk /dev/sda: 1999.3 GB, 1999307276288 bytes
255 heads, 63 sectors/track, 243068 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes
Sector size (logical/physical): 512 bytes / 4096 bytes
I/O size (minimum/optimal): 4096 bytes / 4096 bytes
Disk identifier: 0x0009e3bd

   Device Boot      Start         End      Blocks   Id  System
/dev/sda1   *           1          26      204800   83  Linux
Partition 1 does not end on cylinder boundary.
/dev/sda2              26        2115    16777216   82  Linux swap / Solaris
/dev/sda3            2115      243069  1935465472   83  Linux

3、df

查看磁盘使用情况,可显示挂载点(文件系统)

[root@xxx~]# df -h
Filesystem            Size  Used Avail Use% Mounted on
/dev/sda3             1.8T  1.2T  517G  71% /
tmpfs                 7.9G  4.0K  7.9G   1% /dev/shm
/dev/sda1             194M   33M  152M  18% /boot

注:

/dev/shm/是一个使用就是tmpfs文件系统的设备,其实就是一个特殊的文件系统。redhat中默认大小为物理内存的一半,使用时不用mkfs格式化。

tmpfs是Linux/Unix系统上的一种基于内存的虚拟文件系统。tmpfs可以使用您的内存或swap分区来存储文件(即它的存储空间在virtual memory 中, VM由real memory和swap组成)。由此可见,tmpfs主要存储暂存的文件。它有如下2个优势 : 1. 动态文件系统的大小。2. tmpfs 使用VM建的文件系统,速度当然快。3.重启后数据丢失。

4、cat /proc/partitions

有点类似与lsblk,简洁但信息较少。

[root@swnode2 ~]#  cat /proc/partitions
major minor  #blocks  name

   8        0 1952448512 sda
   8        1     204800 sda1
   8        2   16777216 sda2
   8        3 1935465472 sda3

五、网卡

1、lspci |grep -i 'eth'

查看网卡硬件信息

[root@xxx~]# lspci |grep -i 'eth'
01:00.0 Ethernet controller: Intel Corporation Ethernet Controller 10-Gigabit X540-AT2 (rev 01)
01:00.1 Ethernet controller: Intel Corporation Ethernet Controller 10-Gigabit X540-AT2 (rev 01)

2、ifconfig

查看系统的所有网络接口

[root@xxx~]# ifconfig
eth0      Link encap:Ethernet  HWaddr 00:25:90:F9:DB:BE
          inet addr:192.168.12.121  Bcast:192.168.12.255  Mask:255.255.255.0
          inet6 addr: fe80::225:90ff:fef9:dbbe/64 Scope:Link
          UP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1
          RX packets:1147482001 errors:0 dropped:5994 overruns:0 frame:0
          TX packets:1043105972 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:1000
          RX bytes:8785000769357 (7.9 TiB)  TX bytes:129632779646 (120.7 GiB)

eth1      Link encap:Ethernet  HWaddr 00:25:90:F9:DB:BF
          inet addr:192.168.11.121  Bcast:192.168.11.255  Mask:255.255.255.0
          inet6 addr: fe80::225:90ff:fef9:dbbf/64 Scope:Link
          UP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1
          RX packets:5413 errors:0 dropped:0 overruns:0 frame:0
          TX packets:12 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:1000
          RX bytes:623902 (609.2 KiB)  TX bytes:912 (912.0 b)

lo        Link encap:Local Loopback            #本地环回
          inet addr:127.0.0.1  Mask:255.0.0.0
          inet6 addr: ::1/128 Scope:Host
          UP LOOPBACK RUNNING  MTU:16436  Metric:1
          RX packets:22438196 errors:0 dropped:0 overruns:0 frame:0
          TX packets:22438196 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:0
          RX bytes:2936283227 (2.7 GiB)  TX bytes:2936283227 (2.7 GiB)

3、ip add show

[root@xxx~]# ip add show
1: lo: <LOOPBACK,UP,LOWER_UP> mtu 16436 qdisc noqueue state UNKNOWN
    link/loopback 00:00:00:00:00:00 brd 00:00:00:00:00:00
    inet 127.0.0.1/8 scope host lo
    inet6 ::1/128 scope host
       valid_lft forever preferred_lft forever
2: eth0: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc mq state UP qlen 1000
    link/ether 00:25:90:f9:db:be brd ff:ff:ff:ff:ff:ff
    inet 192.168.12.121/24 brd 192.168.12.255 scope global eth0
    inet6 fe80::225:90ff:fef9:dbbe/64 scope link
       valid_lft forever preferred_lft forever
3: eth1: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc mq state UP qlen 1000
    link/ether 00:25:90:f9:db:bf brd ff:ff:ff:ff:ff:ff
    inet 192.168.11.121/24 brd 192.168.11.255 scope global eth1
    inet6 fe80::225:90ff:fef9:dbbf/64 scope link
       valid_lft forever preferred_lft forever

4、ip link show

[root@xxx~]# ip link show
1: lo: <LOOPBACK,UP,LOWER_UP> mtu 16436 qdisc noqueue state UNKNOWN
    link/loopback 00:00:00:00:00:00 brd 00:00:00:00:00:00
2: eth0: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc mq state UP qlen 1000
    link/ether 00:25:90:f9:db:be brd ff:ff:ff:ff:ff:ff
3: eth1: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc mq state UP qlen 1000
    link/ether 00:25:90:f9:db:bf brd ff:ff:ff:ff:ff:ff

5、ethtool

如果要查看某个网络接口的详细信息,例如eth0的详细参数和指标

[root@swnode2 ~]# ethtool eth0
Settings for eth0:
        Supported ports: [ TP ]
        Supported link modes:   100baseT/Full
                                1000baseT/Full
                                10000baseT/Full    #支持万兆半双工、全双工模式
        Supported pause frame use: No
        Supports auto-negotiation: Yes       #支持自适应模式,一般都支持
        Advertised link modes:  100baseT/Full
                                1000baseT/Full
                                10000baseT/Full
        Advertised pause frame use: No
        Advertised auto-negotiation: Yes     #默认使用自适应模式
        Speed: 1000Mb/s         #现在的网卡速度是1000Mb,网卡使用自适应模式,推测路由是1000M,导致万兆网卡变成支持千兆      
        Duplex: Full            #全双工
        Port: Twisted Pair
        PHYAD: 0
        Transceiver: external
        Auto-negotiation: on
        MDI-X: Unknown
        Supports Wake-on: umbg
        Wake-on: g
        Current message level: 0x00000007 (7)
                               drv probe link
        Link detected: yes      #表示有网线连接和路由是通的

六、光盘


   插入CD光碟后,光碟文件是 /dev/cdrom,
   因此只需 mount /dev/cdrom mount_point 即可。

   [root@xxx tmp]# mount /dev/cdrom mount_point
   mount: block device /dev/cdrom is write-protected, mounting read-only

   其实仔细看一下,光驱的设备文件是 hdc 

   [root@miix tmp]# ls -l /dev/cdrom*
   lrwxrwxrwx 1 root root 3 01-08 08:54 /dev/cdrom -> hdc
   lrwxrwxrwx 1 root root 3 01-08 08:54 /dev/cdrom-hdc -> hdc

因此我们也可以这样 mount /dev/hdc mount_point
  如果光驱里没放入有效光盘,则报错:

  [root@miix tmp]# mount /dev/hdc mount_point
   mount: 找不到介质

七、USB

其实通过 fdisk -l 命令可以查看到接入的U盘信息,本人的U盘信息如下:
  
   Disk /dev/sda: 2012 MB, 2012217344 bytes
   16 heads, 32 sectors/track, 7676 cylinders
   Units = cylinders of 512 * 512 = 262144 bytes
  
      Device Boot      Start         End      Blocks   Id  System
   /dev/sda1   *          16        7676     1961024    b  W95 FAT32
  
   U盘的设备文件是 /dev/sda,2G大小,FAT32格式。
  
   如果用户登陆的不是Linux图形界面,U盘不会自动挂载上来。
   此时可以通过手工挂载(mount):
   mount /dev/sda1 mount_point
   以上命令将U盘挂载到当前目录的 mount_point 目录,注意挂的是 sda1 不是 sda。
   卸载命令是 umount mount_point
  
   Linux默认没有自带支持NTFS格式磁盘的驱动,但对FAT32支持良好,挂载的时候一般不需要 -t vfat 参数 。
   如果支持ntfs,对ntfs格式的磁盘分区应使用 -t ntfs 参数。
   如果出现乱码情况,可以考虑用 -o iocharset=字符集 参数。
  
   可以通过 lsusb 命令查看 USB 设备信息哦:
    [root@miix tmp]# lsusb
   Bus 001 Device 001: ID 0000:0000
   Bus 002 Device 001: ID 0000:0000
   Bus 003 Device 001: ID 0000:0000
   Bus 004 Device 002: ID 0951:1613 Kingston Technology
   Bus 004 Device 001: ID 0000:0000

八、其他

查看pci信息,即主板所有硬件槽信息,包括CPU、内存、网卡等等。

lspci
00:00.0 Host bridge: Intel Corporation 2nd Generation Core Processor Family DRAM Controller (rev 09) #主板芯片
00:02.0 VGA compatible controller: Intel Corporation 2nd Generation Core Processor Family Integrated Graphics Controller (rev 09) #显卡
00:14.0 USB controller: Intel Corporation Panther Point USB xHCI Host Controller (rev 04) #usb控制器
00:16.0 Communication controller: Intel Corporation Panther Point MEI Controller #1 (rev 04)
00:1a.0 USB controller: Intel Corporation Panther Point USB Enhanced Host Controller #2 (rev 04)
00:1b.0 Audio device: Intel Corporation Panther Point High Definition Audio Controller (rev 04) #声卡
00:1c.0 PCI bridge: Intel Corporation Panther Point PCI Express Root Port 1 (rev c4) #pci 插槽
00:1c.2 PCI bridge: Intel Corporation Panther Point PCI Express Root Port 3 (rev c4)
00:1c.3 PCI bridge: Intel Corporation Panther Point PCI Express Root Port 4 (rev c4)
00:1d.0 USB controller: Intel Corporation Panther Point USB Enhanced Host Controller #1 (rev 04)
00:1f.0 ISA bridge: Intel Corporation Panther Point LPC Controller (rev 04)
00:1f.2 IDE interface: Intel Corporation Panther Point 4 port SATA Controller [IDE mode] (rev 04) #硬盘接口
00:1f.3 SMBus: Intel Corporation Panther Point SMBus Controller (rev 04)
00:1f.5 IDE interface: Intel Corporation Panther Point 2 port SATA Controller [IDE mode] (rev 04) #硬盘接口
02:00.0 Ethernet controller: Realtek Semiconductor Co., Ltd. RTL8111/8168B PCI Express Gigabit Ethernet controller (rev 06) #网卡
03:00.0 PCI bridge: Integrated Technology Express, Inc. Device 8893 (rev 41)

结合grep 关键字进行信息查看

更详细的信息:lspci -v 或者 lspci -vv

设备树:lscpi -t

Logo

更多推荐