盒子
盒子

Linux系统信息查看(二)


1.查看系统内核参数

1
2
3
4
5
6
7
8
9
10
11
$ cat /proc/cmdline
BOOT_IMAGE=/boot/vmlinuz-4.2.0-34-generic root=UUID=b0d331a7-e90a-481e-98af-d59b9a26b342 ro quiet splash vt.handoff=7
$ sysctl -a | more
sysctl: permission denied on key 'fs.protected_hardlinks'
sysctl: abi.vsyscall32 = 1
permission denied on key 'fs.protected_symlinks'
debug.exception-trace = 1
debug.kprobes-optimization = 1
dev.cdrom.autoclose = 1
dev.cdrom.autoeject = 0
(信息较多,部分忽略)

2.查看系统内核架构(32 bit或者64 bit)

1
2
3
4
5
6
$ uname -m
x86_64
$ getconf LONG_BIT
64
$ arch
x86_64

3.查看系统磁盘信息

查看所有安装的磁盘和大小

1
2
3
4
5
6
7
8
9
10
11
$ sudo fdisk -l | grep '^Disk /dev'
Partition 2 does not start on physical sector boundary.
Disk /dev/ram0: 64 MiB, 67108864 bytes, 131072 sectors
Disk /dev/ram1: 64 MiB, 67108864 bytes, 131072 sectors
Disk /dev/ram2: 64 MiB, 67108864 bytes, 131072 sectors
Disk /dev/ram3: 64 MiB, 67108864 bytes, 131072 sectors
Disk /dev/ram4: 64 MiB, 67108864 bytes, 131072 sectors
Disk /dev/ram5: 64 MiB, 67108864 bytes, 131072 sectors
Disk /dev/ram6: 64 MiB, 67108864 bytes, 131072 sectors
Disk /dev/ram7: 64 MiB, 67108864 bytes, 131072 sectors
......

查看某一个磁盘分区(以/dev/sda为例)

1
2
3
4
5
6
7
8
9
$ sudo fdisk -l /dev/sda
Disk /dev/sda: 931.5 GiB, 1000204886016 bytes, 1953525168 sectors
Units: sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 4096 bytes
I/O size (minimum/optimal): 4096 bytes / 4096 bytes
Disklabel type: dos
Disk identifier: 0x2856e6e4
设备 启动 Start 末尾 扇区 Size Id 类型
/dev/sda1 * 2048 1953523711 1953521664 931.5G 83 Linux

查看所有的块设备

1
2
3
4
5
6
7
8
9
$ lsblk
NAME MAJ:MIN RM SIZE RO TYPE MOUNTPOINT
sda 8:0 0 931.5G 0 disk
└─sda1 8:1 0 931.5G 0 part /HDD
sdb 8:16 0 238.5G 0 disk
├─sdb1 8:17 0 1.9G 0 part [SWAP]
├─sdb2 8:18 0 1K 0 part
└─sdb5 8:21 0 236.6G 0 part /
sr0 11:0 1 1024M 0 rom

查看文件系统的使用情况

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
$ df
文件系统 1K-块 已用 可用 已用% 挂载点
udev 8144012 0 8144012 0% /dev
tmpfs 1632264 9720 1622544 1% /run
/dev/sdb5 244031768 9722628 221889968 5% /
tmpfs 8161312 55784 8105528 1% /dev/shm
tmpfs 5120 4 5116 1% /run/lock
tmpfs 8161312 0 8161312 0% /sys/fs/cgroup
/dev/sda1 961301832 26746880 885700528 3% /HDD
cgmfs 100 0 100 0% /run/cgmanager/fs
tmpfs 1632264 64 1632200 1% /run/user/1000
$ df -H
文件系统 容量 已用 可用 已用% 挂载点
udev 8.4G 0 8.4G 0% /dev
tmpfs 1.7G 10M 1.7G 1% /run
/dev/sdb5 250G 10G 228G 5% /
tmpfs 8.4G 58M 8.4G 1% /dev/shm
tmpfs 5.3M 4.1k 5.3M 1% /run/lock
tmpfs 8.4G 0 8.4G 0% /sys/fs/cgroup
/dev/sda1 985G 28G 907G 3% /HDD
cgmfs 103k 0 103k 0% /run/cgmanager/fs
tmpfs 1.7G 66k 1.7G 1% /run/user/1000
$ df -HT
文件系统 类型 容量 已用 可用 已用% 挂载点
udev devtmpfs 8.4G 0 8.4G 0% /dev
tmpfs tmpfs 1.7G 10M 1.7G 1% /run
/dev/sdb5 ext4 250G 10G 228G 5% /
tmpfs tmpfs 8.4G 58M 8.3G 1% /dev/shm
tmpfs tmpfs 5.3M 4.1k 5.3M 1% /run/lock
tmpfs tmpfs 8.4G 0 8.4G 0% /sys/fs/cgroup
/dev/sda1 ext4 985G 28G 907G 3% /HDD
cgmfs tmpfs 103k 0 103k 0% /run/cgmanager/fs
tmpfs tmpfs 1.7G 66k 1.7G 1% /run/user/1000

查看挂载的文件系统

1
2
3
4
5
6
7
$ mount
sysfs on /sys type sysfs (rw,nosuid,nodev,noexec,relatime)
proc on /proc type proc (rw,nosuid,nodev,noexec,relatime)
udev on /dev type devtmpfs (rw,nosuid,relatime,size=8144012k,nr_inodes=2036003,mode=755)
devpts on /dev/pts type devpts (rw,nosuid,noexec,relatime,gid=5,mode=620,ptmxmode=000)
tmpfs on /run type tmpfs
......

4.查看系统PCI设备的硬件信息

1
2
3
4
5
$ lspci
00:00.0 Host bridge: Intel Corporation 3rd Gen Core processor DRAM Controller (rev 09)
00:01.0 PCI bridge: Intel Corporation Xeon E3-1200 v2/3rd Gen Core processor PCI Express Root Port (rev 09)
00:02.0 VGA compatible controller: Intel Corporation 3rd Gen Core processor Graphics Controller (rev 09)
...

5.查看系统USB设备信息

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
$ lsusb
Bus 004 Device 004: ID 04f2:b34c Chicony Electronics Co., Ltd
Bus 004 Device 003: ID 147e:1002 Upek Biometric Touchchip/Touchstrip Fingerprint Sensor
Bus 004 Device 002: ID 8087:0024 Intel Corp. Integrated Rate Matching Hub
Bus 004 Device 001: ID 1d6b:0002 Linux Foundation 2.0 root hub
Bus 003 Device 002: ID 8087:0024 Intel Corp. Integrated Rate Matching Hub
Bus 003 Device 001: ID 1d6b:0002 Linux Foundation 2.0 root hub
Bus 002 Device 001: ID 1d6b:0003 Linux Foundation 3.0 root hub
Bus 001 Device 002: ID 046d:c537 Logitech, Inc.
Bus 001 Device 001: ID 1d6b:0002 Linux Foundation 2.0 root hub
$ lsusb -vt
/: Bus 04.Port 1: Dev 1, Class=root_hub, Driver=ehci-pci/2p, 480M
|__ Port 1: Dev 2, If 0, Class=Hub, Driver=hub/8p, 480M
|__ Port 5: Dev 3, If 0, Class=Vendor Specific Class, Driver=, 12M
|__ Port 6: Dev 4, If 0, Class=Video, Driver=uvcvideo, 480M
|__ Port 6: Dev 4, If 1, Class=Video, Driver=uvcvideo, 480M
/: Bus 03.Port 1: Dev 1, Class=root_hub, Driver=ehci-pci/2p, 480M
|__ Port 1: Dev 2, If 0, Class=Hub, Driver=hub/6p, 480M
/: Bus 02.Port 1: Dev 1, Class=root_hub, Driver=xhci_hcd/4p, 5000M
/: Bus 01.Port 1: Dev 1, Class=root_hub, Driver=xhci_hcd/4p, 480M
|__ Port 3: Dev 2, If 0, Class=Human Interface Device, Driver=usbhid, 12M
|__ Port 3: Dev 2, If 1, Class=Human Interface Device, Driver=usbhid, 12M

6.查看系统无线设备信息

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
$ iwconfig
enp4s0f2 no wireless extensions.
lo no wireless extensions.
wlp3s0 IEEE 802.11bgn ESSID:"stdu.edu.cn"
Mode:Managed Frequency:2.437 GHz Access Point: 26:14:4B:55:AE:53
Bit Rate=72.2 Mb/s Tx-Power=20 dBm
Retry short limit:7 RTS thr=2347 B Fragment thr:off
Power Management:off
Link Quality=40/70 Signal level=-70 dBm
Rx invalid nwid:0 Rx invalid crypt:0 Rx invalid frag:0
Tx excessive retries:0 Invalid misc:1097 Missed beacon:0
$ watch -n 1 cat /proc/net/wireless
(实时显示)
$ wavemon
(动态显示无线网络质量等信息)

注意:执行上述wavemon指令时需要先执行sudo apt-get install wavemon

7.查看系统VGA等图形设备信息

1
2
3
4
5
6
7
8
9
$ lspci | grep -i vga
00:02.0 VGA compatible controller: Intel Corporation 3rd Gen Core processor Graphics Controller (rev 09)
01:00.0 VGA compatible controller: NVIDIA Corporation GK107M [GeForce GTX 660M] (rev a1)
$ lspci -vvnn | grep VGA
Control: I/O- Mem+ BusMaster+ SpecCycle- MemWINV- VGASnoop- ParErr- Stepping- SERR- FastB2B- DisINTx-
Control: I/O+ Mem+ BusMaster+ SpecCycle- MemWINV- VGASnoop- ParErr- Stepping- SERR- FastB2B- DisINTx+
BridgeCtl: Parity- SERR- NoISA- VGA- MAbort- >Reset- FastB2B-
00:02.0 VGA compatible controller [0300]: Intel Corporation 3rd Gen Core processor Graphics Controller [8086:0166] (rev 09) (prog-if 00 [VGA controller])
......

查看NVIDIA设备

1
$ nvidia-smi

或者

1
$ nvidia-settings

查看AMD/ATI显卡设备信息

1
$ fglrxinfo

查看系统unity版本

1
2
$ unity --version
unity 7.3.3

查看系统视频设备信息

1
2
$ lspci | grep -i audio
00:1b.0 Audio device: Intel Corporation 7 Series/C210 Series Chipset Family High Definition Audio Controller (rev 04)

或者

1
2
3
$ cat /proc/asound/cards
0 [PCH ]: HDA-Intel - HDA Intel PCH
HDA Intel PCH at 0xf7a10000 irq 32

或者

1
2
3
4
5
$ arecord -l
**** CAPTURE 硬體裝置清單 ****
card 0: PCH [HDA Intel PCH], device 0: ALC269VB Analog [ALC269VB Analog]
子设备: 1/1
子设备 #0: subdevice #0

8.查看电池信息

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
$ upower -i /org/freedesktop/UPower/devices/battery_BAT0
native-path: (null)
power supply: no
updated: 1970年01月01日 星期四 08时00分00秒 (1458648160 seconds ago)
has history: no
has statistics: no
unknown
warning-level: unknown
icon-name: '(null)'
$ acpi -V
Battery 0: Full, 100%
Battery 0: design capacity 5200 mAh, last full capacity 3701 mAh = 71%
Adapter 0: on-line
Thermal 0: ok, 56.0 degrees C
Thermal 0: trip point 0 switches to mode critical at temperature 149.8 degrees C
Cooling 0: x86_pkg_temp no state information available
Cooling 1: intel_powerclamp no state information available
Cooling 2: LCD 6 of 7
Cooling 3: Processor 0 of 3
Cooling 4: Processor 0 of 3
Cooling 5: Processor 0 of 3
Cooling 6: Processor 0 of 3
Cooling 7: Processor 0 of 3
Cooling 8: Processor 0 of 3
Cooling 9: Processor 0 of 3
Cooling 10: Processor 0 of 3

9.查看系统运行了多长时间

1
2
3
4
5
6
7
8
9
10
$ uptime
20:03:41 up 40 min, 2 users, load average: 0.31, 0.26, 0.29
$ who
vil :0 2016-03-22 19:22 (:0)
evil pts/2 2016-03-22 19:32 (:0)
$ w
20:04:01 up 41 min, 2 users, load average: 0.29, 0.26, 0.29
USER TTY FROM LOGIN@ IDLE JCPU PCPU WHAT
evil :0 :0 19:22 ?xdm? 12:38 0.31s /sbin/upstart --user
evil pts/2 :0 19:32 0.00s 0.15s 0.00s w

10.查看系统负载

1
2
3
$ cat /proc/loadavg
0.46 0.30 0.30 1/676 5626
$ sudo top

11.查看系统重启和关机记录

1
2
3
4
5
6
7
8
9
10
11
$ last reboot
reboot system boot 4.2.0-34-generic Tue Mar 22 19:22 still running
reboot system boot 4.2.0-34-generic Tue Mar 22 18:37 - 19:22 (00:45)
reboot system boot 4.2.0-34-generic Tue Mar 22 15:49 - 17:22 (01:32)
reboot system boot 4.2.0-34-generic Tue Mar 22 14:50 - 15:49 (00:58)
reboot system boot 4.2.0-34-generic Tue Mar 22 08:11 - 13:16 (05:04)
reboot system boot 4.2.0-34-generic Mon Mar 21 22:44 - 22:47 (00:03)
reboot system boot 4.2.0-34-generic Mon Mar 21 18:16 - 22:47 (04:31)
......
$ last shutdown
wtmp begins Thu Mar 17 19:59:43 2016

12.查看系统运行级别

1
2
3
4
$ runlevel
N 5
$ who -r
运行级别 5 2016-03-22 19:23