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