CentOS7下查詢硬件信息

原文:https://blog.csdn.net/pwb1994001/article/details/80896267java

由於我的須要,整理的

參考:https://blog.csdn.net/dream_broken/article/details/52883883 參考:https://blog.csdn.net/lampsunny/article/details/6288457
  • 1
  • 2

一.系統

1.版本

① 確認是64位仍是32位,其餘信息很少mysql

$ uname -a
Linux localhost.localdomain 3.10.0-327.el7.x86_64 #1 SMP Tue Feb 16 17:03:50 UTC 2016 x86_64 x86_64 x86_64 GNU/Linux
  • 1
  • 2

② 看到更多信息linux

$ more /etc/*release :::::::::::::: /etc/centos-release :::::::::::::: CentOS Linux release 7.2.1511 (Core) :::::::::::::: /etc/os-release :::::::::::::: NAME="CentOS Linux" VERSION="7 (Core)" ID="centos" ID_LIKE="rhel fedora" VERSION_ID="7" PRETTY_NAME="CentOS Linux 7 (Core)" ANSI_COLOR="0;31" CPE_NAME="cpe:/o:centos:centos:7" HOME_URL="https://www.centos.org/" BUG_REPORT_URL="https://bugs.centos.org/" CENTOS_MANTISBT_PROJECT="CentOS-7" CENTOS_MANTISBT_PROJECT_VERSION="7" REDHAT_SUPPORT_PRODUCT="centos" REDHAT_SUPPORT_PRODUCT_VERSION="7" :::::::::::::: /etc/redhat-release :::::::::::::: CentOS Linux release 7.2.1511 (Core) :::::::::::::: /etc/system-release :::::::::::::: CentOS Linux release 7.2.1511 (Core)
  • 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
2.CPU

總核數 = 物理CPU個數 × 每顆物理CPU的核數 
總邏輯CPU數 = 物理CPU個數 × 每顆物理CPU的核數 × 超線程數 
① 查看物理CPU個數nginx

$ cat /proc/cpuinfo | grep "physical id" | sort | uniq | wc -l 1
  • 1
  • 2

② 查看每顆物理CPU中core的個數(即核數)redis

$ cat /proc/cpuinfo | grep "cpu cores" | uniq cpu cores : 8
  • 1
  • 2

③ 查看邏輯CPU的個數sql

$ cat /proc/cpuinfo | grep "processor" | wc -l 16
  • 1
  • 2

④ 查看CPU信息(型號)docker

$ cat /proc/cpuinfo | grep name | cut -f2 -d: | uniq -c 16 Intel(R) Xeon(R) CPU E5-2666 v3 @ 2.90GHz
  • 1
  • 2

⑤ 查看CPU詳細信息centos

$ cat /proc/cpuinfo
processor   : 0 vendor_id : GenuineIntel cpu family : 6 model : 63 model name : Intel(R) Xeon(R) CPU E5-2666 v3 @ 2.90GHz stepping : 2 microcode : 0x3c cpu MHz : 2900.028 cache size : 25600 KB physical id : 0 siblings : 16 core id : 0 cpu cores : 8 apicid : 0 initial apicid : 0 fpu : yes fpu_exception : yes cpuid level : 13 wp : yes flags : fpu vme de pse tsc msr pae mce cx8 apic sep mtrr pge mca cmov pat pse36 clflush mmx fxsr sse sse2 ht syscall nx pdpe1gb rdtscp lm constant_tsc rep_good nopl xtopology eagerfpu pni pclmulqdq ssse3 fma cx16 pcid sse4_1 sse4_2 x2apic movbe popcnt tsc_deadline_timer aes xsave avx f16c rdrand hypervisor lahf_lm abm fsgsbase bmi1 avx2 smep bmi2 erms invpcid xsaveopt bogomips : 5800.05 clflush size : 64 cache_alignment : 64 address sizes : 46 bits physical, 48 bits virtual power management:
  • 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
3.運行模式

① 查看CPU運行在多少位模式下api

$ getconf LONG_BIT 64
  • 1
  • 2

② 若是是32,說明當前CPU運行在32bit模式下,但不表明CPU不支持64bitruby

$ cat /proc/cpuinfo | grep flags | grep ' lm ' | wc -l 16
  • 1
  • 2

結果大於0,說明支持64bit計算,lm指long mode,支持lm則是64bit

4.計算機名

① 計算機名

$ hostname localhost.localdomain
  • 1
  • 2
5.查看環境變量

① 環境變量

$ env
XDG_SESSION_ID=4 HOSTNAME=localhost.localdomain SELINUX_ROLE_REQUESTED= TERM=vt100 SHELL=/bin/bash HISTSIZE=1000 SSH_CLIENT=192.168.174.1 58896 22 SELINUX_USE_CURRENT_RANGE= SSH_TTY=/dev/pts/0 USER=root
  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7
  • 8
  • 9
  • 10
  • 11
6.系統運行

① 系統運行時間

$ uptime
 02:16:07 up 36 days, 27 min, 7 users, load average: 1.38, 1.36, 1.34
  • 1
  • 2
02:16:07  // 系統當前時間 up 36 days, 27 min  // 主機已運行時間,36天27分鐘,時間越大,說明你的機器越穩定。 7 users  // 用戶鏈接數,是總鏈接數而不是用戶數 load average: 1.38, 1.36, 1.34  // 系統平均負載,統計最近1,5,15分鐘的系統平均負載
  • 1
  • 2
  • 3
  • 4

② 查看平均負載

$ cat /proc/loadavg 1.80 1.53 1.41 4/3909 4106
  • 1
  • 2

前面三個值分別對應系統當前1分鐘、5分鐘、15分鐘內的平均load; 
後面的1個分數,分母表示系統進程總數,分子表示正在運行的進程數; 
最後一個數字表示最近運行的進程ID。

二.資源

1.內存

① 內存詳細信息

$ cat /proc/meminfo
MemTotal: 30440564 kB MemFree: 1292332 kB MemAvailable: 9045208 kB Buffers: 788 kB Cached: 8805368 kB SwapCached: 0 kB Active: 23305524 kB Inactive: 4361900 kB Active(anon): 19620352 kB Inactive(anon): 869288 kB Active(file): 3685172 kB Inactive(file): 3492612 kB Unevictable: 0 kB Mlocked: 0 kB SwapTotal: 0 kB SwapFree: 0 kB Dirty: 1396 kB Writeback: 0 kB AnonPages: 18861432 kB Mapped: 281464 kB Shmem: 1628228 kB Slab: 1021668 kB SReclaimable: 828508 kB SUnreclaim: 193160 kB KernelStack: 66336 kB PageTables: 84196 kB NFS_Unstable: 0 kB Bounce: 0 kB WritebackTmp: 0 kB CommitLimit: 15220280 kB Committed_AS: 36287560 kB VmallocTotal: 34359738367 kB VmallocUsed: 83692 kB VmallocChunk: 34359493624 kB HardwareCorrupted: 0 kB AnonHugePages: 15896576 kB HugePages_Total: 0 HugePages_Free: 0 HugePages_Rsvd: 0 HugePages_Surp: 0 Hugepagesize: 2048 kB DirectMap4k: 284672 kB DirectMap2M: 22784000 kB DirectMap1G: 8388608 kB
  • 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
  • 34
  • 35
  • 36
  • 37
  • 38
  • 39
  • 40
  • 41
  • 42
  • 43
  • 44
  • 45

MemTotal總內存,MemFree可用內存 
② 查看可用內存(-m,單位是m,-g,單位是g)

$ free -m
              total        used        free      shared  buff/cache   available
Mem: 29727 18867 1248 1598 9611 8825 Swap: 0 0 0 $ free -g total used free shared buff/cache available Mem: 29 18 1 1 9 8 Swap: 0 0 0
  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7
  • 8
  • 9

空閒內存:total - used = free + buff/cache

咱們經過free命令查看機器空閒內存時,會發現free的值很小。這主要是由於,在linux中有這麼一種思想,內存不用白不用,所以它儘量的cache和buffer一些數據,以方便下次使用。但實際上這些內存也是能夠馬上拿來使用的。

三.硬盤

1.磁盤和分區

① 查看各分區使用狀況

$ df -h Filesystem Size Used Avail Use% Mounted on /dev/mapper/centos-root 45G 22G 24G 48% / devtmpfs 906M 0 906M 0% /dev tmpfs 921M 96K 921M 1% /dev/shm tmpfs 921M 1004K 920M 1% /run tmpfs 921M 0 921M 0% /sys/fs/cgroup /dev/sda1 497M 195M 303M 40% /boot tmpfs 185M 0 185M 0% /run/user/1001 tmpfs 185M 0 185M 0% /run/user/0
  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7
  • 8
  • 9
  • 10

② 查看指定目錄的大小

$ du -sh /root 1.2G /root 
  • 1
  • 2

③ 查看全部分區

$ fdisk -l
磁盤 /dev/sda:32.2 GB, 32212254720 字節,62914560 個扇區 Units = 扇區 of 1 * 512 = 512 bytes 扇區大小(邏輯/物理):512 字節 / 512 字節 I/O 大小(最小/最佳):512 字節 / 512 字節 磁盤標籤類型:dos 磁盤標識符:0x000a0cd4 設備 Boot Start End Blocks Id System /dev/sda1 * 2048 1026047 512000 83 Linux /dev/sda2 1026048 62914559 30944256 8e Linux LVM 磁盤 /dev/mapper/centos-root:29.5 GB, 29490151424 字節,57597952 個扇區 Units = 扇區 of 1 * 512 = 512 bytes 扇區大小(邏輯/物理):512 字節 / 512 字節 I/O 大小(最小/最佳):512 字節 / 512 字節 磁盤 /dev/mapper/centos-swap:2147 MB, 2147483648 字節,4194304 個扇區 Units = 扇區 of 1 * 512 = 512 bytes 扇區大小(邏輯/物理):512 字節 / 512 字節 I/O 大小(最小/最佳):512 字節 / 512 字節 磁盤 /dev/mapper/centos-docker--poolmeta:33 MB, 33554432 字節,65536 個扇區 Units = 扇區 of 1 * 512 = 512 bytes 扇區大小(邏輯/物理):512 字節 / 512 字節 I/O 大小(最小/最佳):512 字節 / 512 字節 磁盤 /dev/mapper/docker-253:0-101330881-pool:107.4 GB, 107374182400 字節,209715200 個扇區 Units = 扇區 of 1 * 512 = 512 bytes 扇區大小(邏輯/物理):512 字節 / 512 字節 I/O 大小(最小/最佳):65536 字節 / 65536 字節 
  • 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
  • 34

④ 查看全部交換分區

$ swapon -s 文件名 類型 大小 已用 權限 /dev/dm-1 partition 2097148 8 -1 
  • 1
  • 2
  • 3

四.網絡

1.網絡屬性信息

① 查看全部網絡接口的屬性

$ ifconfig
docker0: flags=4099<UP,BROADCAST,MULTICAST> mtu 1500 inet 172.17.0.1 netmask 255.255.0.0 broadcast 0.0.0.0 ether 02:42:e1:b8:a5:4f txqueuelen 0 (Ethernet) RX packets 0 bytes 0 (0.0 B) RX errors 0 dropped 0 overruns 0 frame 0 TX packets 0 bytes 0 (0.0 B) TX errors 0 dropped 0 overruns 0 carrier 0 collisions 0 eth0: flags=4163<UP,BROADCAST,RUNNING,MULTICAST> mtu 1500 inet 192.168.174.129 netmask 255.255.255.0 broadcast 192.168.174.255 inet6 fe80::20c:29ff:fe50:b3b4 prefixlen 64 scopeid 0x20<link> ether 00:0c:29:50:b3:b4 txqueuelen 1000 (Ethernet) RX packets 28649 bytes 38411280 (36.6 MiB) RX errors 0 dropped 0 overruns 0 frame 0 TX packets 8937 bytes 1226914 (1.1 MiB) TX errors 0 dropped 0 overruns 0 carrier 0 collisions 0 lo: flags=73<UP,LOOPBACK,RUNNING> mtu 65536 inet 127.0.0.1 netmask 255.0.0.0 inet6 ::1 prefixlen 128 scopeid 0x10<host> loop txqueuelen 0 (Local Loopback) RX packets 4 bytes 340 (340.0 B) RX errors 0 dropped 0 overruns 0 frame 0 TX packets 4 bytes 340 (340.0 B) TX errors 0 dropped 0 overruns 0 carrier 0 collisions 0 virbr0: flags=4099<UP,BROADCAST,MULTICAST> mtu 1500 inet 192.168.122.1 netmask 255.255.255.0 broadcast 192.168.122.255 ether 00:00:00:00:00:00 txqueuelen 0 (Ethernet) RX packets 0 bytes 0 (0.0 B) RX errors 0 dropped 0 overruns 0 frame 0 TX packets 0 bytes 0 (0.0 B) TX errors 0 dropped 0 overruns 0 carrier 0 collisions 0 
  • 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
  • 34

② 帶寬

$ ethtool ens192(網卡名)
Settings for ens192: Supported ports: [ TP ] Supported link modes: 1000baseT/Full 10000baseT/Full Supported pause frame use: No Supports auto-negotiation: No Advertised link modes: Not reported Advertised pause frame use: No Advertised auto-negotiation: No Speed: 10000Mb/s Duplex: Full Port: Twisted Pair PHYAD: 0 Transceiver: internal Auto-negotiation: off MDI-X: Unknown Supports Wake-on: uag Wake-on: d Link detected: yes 
  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7
  • 8
  • 9
  • 10
  • 11
  • 12
  • 13
  • 14
  • 15
  • 16
  • 17
  • 18
  • 19
  • 20

主要查看speed

③ 查看路由表

$ route -n Kernel IP routing table Destination Gateway Genmask Flags Metric Ref Use Iface 0.0.0.0 172.31.16.1 0.0.0.0 UG 0 0 0 eth0 172.17.0.0 0.0.0.0 255.255.0.0 U 0 0 0 docker0 172.18.0.0 0.0.0.0 255.255.0.0 U 0 0 0 br-b3fca78f9ec2 172.31.16.0 0.0.0.0 255.255.240.0 U 0 0 0 eth0
  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7
  • 8

④ 查看全部監聽端口

$ netstat -ntpl Active Internet connections (only servers) Proto Recv-Q Send-Q Local Address Foreign Address State PID/Program name tcp 0 0 127.0.0.1:10248 0.0.0.0:* LISTEN 48609/kubelet tcp 0 0 127.0.0.1:9000 0.0.0.0:* LISTEN 112434/java tcp 0 0 127.0.0.1:10249 0.0.0.0:* LISTEN 15725/kube-proxy tcp 0 0 172.31.24.20:10250 0.0.0.0:* LISTEN 48609/kubelet tcp 0 0 127.0.0.1:50090 0.0.0.0:* LISTEN 112806/java tcp 0 0 0.0.0.0:26380 0.0.0.0:* LISTEN 119314/redis-sentin tcp 0 0 0.0.0.0:6380 0.0.0.0:* LISTEN 121036/./redis-serv tcp 0 0 0.0.0.0:26381 0.0.0.0:* LISTEN 126277/redis-sentin tcp 0 0 0.0.0.0:6381 0.0.0.0:* LISTEN 94302/redis-server tcp 0 0 0.0.0.0:26382 0.0.0.0:* LISTEN 130400/redis-sentin tcp 0 0 0.0.0.0:6382 0.0.0.0:* LISTEN 70223/redis-server tcp 0 0 0.0.0.0:17070 0.0.0.0:* LISTEN 9519/nginx: master tcp 0 0 172.31.24.20:10255 0.0.0.0:* LISTEN 48609/kubelet tcp 0 0 0.0.0.0:20880 0.0.0.0:* LISTEN 80641/java tcp 0 0 0.0.0.0:19888 0.0.0.0:* LISTEN 9519/nginx: master tcp 0 0 0.0.0.0:8080 0.0.0.0:* LISTEN 39892/java tcp 0 0 0.0.0.0:28080 0.0.0.0:* LISTEN 39892/java tcp 0 0 0.0.0.0:20050 0.0.0.0:* LISTEN 1181/zabbix_agentd tcp 0 0 0.0.0.0:21268 0.0.0.0:* LISTEN 80641/java tcp 0 0 0.0.0.0:8020 0.0.0.0:* LISTEN 1325/nginx: master tcp 0 0 127.0.0.1:50070 0.0.0.0:* LISTEN 112434/java tcp 0 0 0.0.0.0:50071 0.0.0.0:* LISTEN 9519/nginx: master tcp 0 0 0.0.0.0:8088 0.0.0.0:* LISTEN 80641/java tcp 0 0 0.0.0.0:50072 0.0.0.0:* LISTEN 9519/nginx: master tcp 0 0 0.0.0.0:50073 0.0.0.0:* LISTEN 9519/nginx: master tcp 0 0 0.0.0.0:50074 0.0.0.0:* LISTEN 9519/nginx: master tcp 0 0 0.0.0.0:50010 0.0.0.0:* LISTEN 112593/java tcp 0 0 0.0.0.0:50075 0.0.0.0:* LISTEN 112593/java tcp 0 0 0.0.0.0:27070 0.0.0.0:* LISTEN 9519/nginx: master tcp 0 0 0.0.0.0:8030 0.0.0.0:* LISTEN 15480/nginx: master tcp 0 0 127.0.0.1:25664 0.0.0.0:* LISTEN 112593/java tcp 0 0 0.0.0.0:36000 0.0.0.0:* LISTEN 101488/sshd tcp 0 0 0.0.0.0:11970 0.0.0.0:* LISTEN 80641/java tcp 0 0 172.31.24.20:4194 0.0.0.0:* LISTEN 48609/kubelet tcp 0 0 127.0.0.1:50020 0.0.0.0:* LISTEN 112593/java tcp 0 0 0.0.0.0:18086 0.0.0.0:* LISTEN 80641/java tcp6 0 0 :::3306 :::* LISTEN 51298/mysqld tcp6 0 0 :::17070 :::* LISTEN 9519/nginx: master tcp6 0 0 :::19888 :::* LISTEN 9519/nginx: master tcp6 0 0 :::10256 :::* LISTEN 15725/kube-proxy tcp6 0 0 :::21 :::* LISTEN 63183/vsftpd tcp6 0 0 :::8087 :::* LISTEN 19337/java tcp6 0 0 :::50071 :::* LISTEN 9519/nginx: master
  • 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
  • 34
  • 35
  • 36
  • 37
  • 38
  • 39
  • 40
  • 41
  • 42
  • 43
  • 44
  • 45
  • 46
  • 47

⑤ 查看全部已經創建的鏈接

$ netstat -napt Active Internet connections (only servers) Proto Recv-Q Send-Q Local Address Foreign Address State PID/Program name tcp 0 0 127.0.0.1:10248 0.0.0.0:* LISTEN 48609/kubelet tcp 0 0 127.0.0.1:9000 0.0.0.0:* LISTEN 112434/java tcp 0 0 127.0.0.1:10249 0.0.0.0:* LISTEN 15725/kube-proxy tcp 0 0 172.31.24.20:10250 0.0.0.0:* LISTEN 48609/kubelet tcp 0 0 127.0.0.1:50090 0.0.0.0:* LISTEN 112806/java tcp 0 0 0.0.0.0:26380 0.0.0.0:* LISTEN 119314/redis-sentin tcp 0 0 0.0.0.0:6380 0.0.0.0:* LISTEN 121036/./redis-serv tcp 0 0 0.0.0.0:26381 0.0.0.0:* LISTEN 126277/redis-sentin tcp 0 0 0.0.0.0:6381 0.0.0.0:* LISTEN 94302/redis-server tcp 0 0 0.0.0.0:26382 0.0.0.0:* LISTEN 130400/redis-sentin tcp 0 0 0.0.0.0:6382 0.0.0.0:* LISTEN 70223/redis-server tcp 0 0 0.0.0.0:17070 0.0.0.0:* LISTEN 9519/nginx: master tcp 0 0 172.31.24.20:10255 0.0.0.0:* LISTEN 48609/kubelet tcp 0 0 0.0.0.0:20880 0.0.0.0:* LISTEN 80641/java tcp 0 0 0.0.0.0:19888 0.0.0.0:* LISTEN 9519/nginx: master tcp 0 0 0.0.0.0:8080 0.0.0.0:* LISTEN 39892/java tcp 0 0 0.0.0.0:28080 0.0.0.0:* LISTEN 39892/java tcp 0 0 0.0.0.0:20050 0.0.0.0:* LISTEN 1181/zabbix_agentd tcp 0 0 0.0.0.0:21268 0.0.0.0:* LISTEN 80641/java tcp 0 0 0.0.0.0:8020 0.0.0.0:* LISTEN 1325/nginx: master tcp 0 0 127.0.0.1:50070 0.0.0.0:* LISTEN 112434/java tcp 0 0 0.0.0.0:50071 0.0.0.0:* LISTEN 9519/nginx: master tcp 0 0 0.0.0.0:8088 0.0.0.0:* LISTEN 80641/java tcp 0 0 0.0.0.0:50072 0.0.0.0:* LISTEN 9519/nginx: master tcp 0 0 0.0.0.0:50073 0.0.0.0:* LISTEN 9519/nginx: master tcp 0 0 0.0.0.0:50074 0.0.0.0:* LISTEN 9519/nginx: master tcp 0 0 0.0.0.0:50010 0.0.0.0:* LISTEN 112593/java tcp 0 0 0.0.0.0:50075 0.0.0.0:* LISTEN 112593/java tcp 0 0 0.0.0.0:27070 0.0.0.0:* LISTEN 9519/nginx: master tcp 0 0 0.0.0.0:8030 0.0.0.0:* LISTEN 15480/nginx: master tcp 0 0 127.0.0.1:25664 0.0.0.0:* LISTEN 112593/java tcp 0 0 0.0.0.0:36000 0.0.0.0:* LISTEN 101488/sshd tcp 0 0 0.0.0.0:11970 0.0.0.0:* LISTEN 80641/java tcp 0 0 172.31.24.20:4194 0.0.0.0:* LISTEN 48609/kubelet tcp 0 0 127.0.0.1:50020 0.0.0.0:* LISTEN 112593/java tcp 0 0 0.0.0.0:18086 0.0.0.0:* LISTEN 80641/java tcp6 0 0 :::3306 :::* LISTEN 51298/mysqld tcp6 0 0 :::17070 :::* LISTEN 9519/nginx: master tcp6 0 0 :::19888 :::* LISTEN 9519/nginx: master tcp6 0 0 :::10256 :::* LISTEN 15725/kube-proxy tcp6 0 0 :::21 :::* LISTEN 63183/vsftpd tcp6 0 0 :::8087 :::* LISTEN 19337/java tcp6 0 0 :::50071 :::* LISTEN 9519/nginx: master
  • 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
  • 34
  • 35
  • 36
  • 37
  • 38
  • 39
  • 40
  • 41
  • 42
  • 43
  • 44
  • 45
  • 46
  • 47

⑥ 查看某端口使用狀況

$ lsof -i:8030(端口號) COMMAND PID USER FD TYPE DEVICE SIZE/OFF NODE NAME nginx 15480 root 7u IPv4 260155918 0t0 TCP *:8030 (LISTEN) nginx 15482 nobody 7u IPv4 260155918 0t0 TCP *:8030 (LISTEN) $ netstat -apn | grep 8030(端口號) tcp 0 0 0.0.0.0:8030 0.0.0.0:* LISTEN 15480/nginx: master
  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7
  • 8
  • 9

五.進程

1.查看進程

① 查看全部進程

$ ps -ef UID PID PPID C STIME TTY TIME CMD root 1 0 0 May28 ? 00:12:45 /usr/lib/systemd/systemd --system --deserialize 20 root 2 0 0 May28 ? 00:00:00 [kthreadd] root 3 2 0 May28 ? 00:05:45 [ksoftirqd/0] root 5 2 0 May28 ? 00:00:00 [kworker/0:0H] root 7 2 0 May28 ? 00:00:05 [migration/0] root 8 2 0 May28 ? 00:00:00 [rcu_bh] root 9 2 0 May28 ? 00:00:00 [rcuob/0] root 10 2 0 May28 ? 00:00:00 [rcuob/1] root 11 2 0 May28 ? 00:00:00 [rcuob/2] root 12 2 0 May28 ? 00:00:00 [rcuob/3] root 13 2 0 May28 ? 00:00:00 [rcuob/4] 
  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7
  • 8
  • 9
  • 10
  • 11
  • 12
  • 13
  • 14
  • 15

能夠經過ps -ef | grep 進程名 進行過濾

$ ps -aux 

USER        PID %CPU %MEM VSZ RSS TTY STAT START TIME COMMAND root 1 0.0 0.0 189908 4196 ? Ss May28 12:45 /usr/lib/systemd/systemd --system --deserialize 20 root 2 0.0 0.0 0 0 ? S May28 0:00 [kthreadd] root 3 0.0 0.0 0 0 ? S May28 5:45 [ksoftirqd/0] root 5 0.0 0.0 0 0 ? S< May28 0:00 [kworker/0:0H] root 7 0.0 0.0 0 0 ? S May28 0:05 [migration/0] root 8 0.0 0.0 0 0 ? S May28 0:00 [rcu_bh] root 9 0.0 0.0 0 0 ? S May28 0:00 [rcuob/0] root 10 0.0 0.0 0 0 ? S May28 0:00 [rcuob/1] root 11 0.0 0.0 0 0 ? S May28 0:00 [rcuob/2] root 12 0.0 0.0 0 0 ? S May28 0:00 [rcuob/3] root 13 0.0 0.0 0 0 ? S May28 0:00 [rcuob/4] root 14 0.0 0.0 0 0 ? S May28 0:00 [rcuob/5]
  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7
  • 8
  • 9
  • 10
  • 11
  • 12
  • 13
  • 14
  • 15

ps -aux 能夠看到進程佔用CPU,內存狀況

② 實時顯示進程狀態

$ top

top - 07:20:17 up 36 days, 5:31, 9 users, load average: 1.78, 1.48, 1.38 Tasks: 669 total, 2 running, 667 sleeping, 0 stopped, 0 zombie %Cpu(s): 2.9 us, 4.9 sy, 0.0 ni, 92.0 id, 0.1 wa, 0.0 hi, 0.0 si, 0.0 st KiB Mem : 30440564 total, 797520 free, 19349712 used, 10293332 buff/cache KiB Swap: 0 total, 0 free, 0 used. 9069184 avail Mem PID USER PR NI VIRT RES SHR S %CPU %MEM TIME+ COMMAND 14124 root 20 0 110092 536 408 R 100.0 0.0 8943:33 agetty 32399 root 20 0 9.932g 1.295g 18276 S 3.0 4.5 224:25.65 java 30791 root 20 0 9456624 314496 7304 S 1.7 1.0 102:43.09 java 60824 root 20 0 9461308 311600 7264 S 1.7 1.0 101:58.13 java 48609 root 20 0 1571064 50992 8996 S 1.0 0.2 153:24.50 kubelet 106830 root 20 0 420984 596 28 S 0.7 0.0 23:16.55 docker-containe 137 root 20 0 0 0 0 S 0.3 0.0 84:51.73 rcu_sched 138 root 20 0 0 0 0 S 0.3 0.0 28:02.18 rcuos/0 143 root 20 0 0 0 0 S 0.3 0.0 14:46.18 rcuos/5 145 root 20 0 0 0 0 S 0.3 0.0 14:36.10 rcuos/7 148 root 20 0 0 0 0 S 0.3 0.0 6:19.49 rcuos/10 152 root 20 0 0 0 0 S 0.3 0.0 6:20.98 rcuos/14 760 root 20 0 26884 1784 976 S 0.3 0.0 2:34.61 systemd-logind 1182 zabbix 20 0 45108 2104 1532 S 0.3 0.0 20:35.96 zabbix_agentd 9312 root 20 0 6126612 1.165g 29680 S 0.3 4.0 1:04.32 java 
  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7
  • 8
  • 9
  • 10
  • 11
  • 12
  • 13
  • 14
  • 15
  • 16
  • 17
  • 18
  • 19
  • 20
  • 21
  • 22
  • 23
  • 24

六.用戶

1.查看用戶

① 查看活動用戶

$ w

root     pts/0 192.168.174.1 Mon Oct 24 09:51 still logged in (unknown :0 :0 Mon Oct 24 09:27 still logged in reboot system boot 3.10.0-327.el7.x Mon Oct 24 09:26 - 11:35 (02:09) root pts/0 192.168.174.1 Fri Oct 21 09:41 - 18:44 (09:03) (unknown :0 :0 Fri Oct 21 09:15 - 18:44 (09:28) reboot system boot 3.10.0-327.el7.x Fri Oct 21 09:15 - 11:35 (3+02:20) root pts/1 192.168.174.1 Thu Oct 20 10:05 - 18:13 (08:08) 
  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7
  • 8
  • 9

② 查看指定用戶的信息

$ id root uid=0(root) gid=0(root) groups=0(root) [root@localhost ~]# id cavan uid=1001(cavan) gid=1001(cavan) groups=1001(cavan)
  • 1
  • 2
  • 3
  • 4
  • 5

③ 查看用戶登陸日誌

$ last 


root     pts/0 192.168.174.1 Mon Oct 24 09:51 still logged in (unknown :0 :0 Mon Oct 24 09:27 still logged in reboot system boot 3.10.0-327.el7.x Mon Oct 24 09:26 - 11:35 (02:09) root pts/0 192.168.174.1 Fri Oct 21 09:41 - 18:44 (09:03) (unknown :0 :0 Fri Oct 21 09:15 - 18:44 (09:28) reboot system boot 3.10.0-327.el7.x Fri Oct 21 09:15 - 11:35 (3+02:20) root pts/1 192.168.174.1 Thu Oct 20 10:05 - 18:13 (08:08) 
  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7
  • 8
  • 9
  • 10

④ 查看系統全部用戶

$ cut -d: -f1 /etc/passwd root bin daemon adm lp sync shutdown halt mail operator games ftp nobody dbus polkitd abrt unbound colord usbmuxd
相關文章
相關標籤/搜索