系统状态检测命令
-
ifconfig
ifconfig命令用于获取网卡配置和网络状态等信息,格式为:
ifconfig [网络设备] [参数]
[root@zhufanyu ~]# ifconfig docker0: flags=4099<UP,BROADCAST,MULTICAST> mtu 1500 inet 172.17.0.1 netmask 255.255.0.0 broadcast 172.17.255.255 inet6 fe80::42:f5ff:fef1:fdf5 prefixlen 64 scopeid 0x20<link> ether 02:42:f5:f1:fd:f5 txqueuelen 0 (Ethernet) RX packets 72254 bytes 13452188 (12.8 MiB) RX errors 0 dropped 0 overruns 0 frame 0 TX packets 69177 bytes 8928970 (8.5 MiB) TX errors 0 dropped 0 overruns 0 carrier 0 collisions 0 eth0: flags=4163<UP,BROADCAST,RUNNING,MULTICAST> mtu 1500 inet 172.30.65.160 netmask 255.255.240.0 broadcast 172.30.79.255 inet6 fe80::216:3eff:fe2e:ac0c prefixlen 64 scopeid 0x20<link> ether 00:16:3e:2e:ac:0c txqueuelen 1000 (Ethernet) RX packets 52384975 bytes 40136969151 (37.3 GiB) RX errors 0 dropped 0 overruns 0 frame 0 TX packets 27048590 bytes 4883198168 (4.5 GiB) 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 1000 (Local Loopback) 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
-
uname
uname命令用于查看系统内核与系统版本等信息,格式为:
uname [-a]
[root@zhufanyu ~]# uname -a Linux zhufanyu 4.18.0-147.5.1.el8_1.x86_64 #1 SMP Wed Feb 5 02:00:39 UTC 2020 x86_64 x86_64 x86_64 GNU/Linux
如果需要查看当前系统的版本信息,则需要查看redhat-release文件
[root@zhufanyu ~]# cat /etc/redhat-release CentOS Linux release 8.1.1911 (Core)
-
who
who 用于查看当前登录主机的用户终端信息, 格式为:
who [参数]
[root@zhufanyu ~]# who root pts/0 2021-01-03 13:17 (27.38.66.188)
-
last
last 命令用于查看所有系统的登录记录,格式为:
last [参数]
[root@zhufanyu ~]# last root pts/0 27.38.66.188 Sun Jan 3 13:17 still logged in root pts/0 27.38.66.188 Sat Jan 2 15:49 - 22:34 (06:44) root pts/0 163.125.140.105 Tue Dec 29 22:23 - 23:24 (01:00)
-
history
history 命令用于显示历史执行过的命令,格式为:
history [参数]
[root@zhufanyu ~]# history 1 hostname zhufanyu 2 top 3 systemctl status sshd 4 blikd 5 blkid 6 cat /etc/sysconfig/network-scripts/ifcfg-eth0 7 cat /etc/sysconfig/network-scripts/ifcfg-eth33 8 cat /etc/sysconfig/network-scripts/ifcfg-e 9 cd / 10 ls 11 mkdir code 12 cd code/ 13 touch test
历史命令会被保存在用户家目录的
.bash_history
文件中,[root@zhufanyu ~]# cat ~/.bash_history
需要清空当前用户的在本机的历史命令就使用
[root@zhufanyu ~]# history -c
-
sosreport
sosreport 命令用于收集系统配置及架构信息并输出诊断文档,格式为
sosreport
[root@zhufanyu ~]# sosreport sosreport (version 3.7) This command will collect diagnostic and configuration information from this CentOS system and installed applications. An archive containing the collected information will be generated in /var/tmp/sos.klc9r3bx and may be provided to a CentOS support representative. Any information provided to CentOS will be treated in accordance with the published support policies at: http://www.centos.org/ The generated archive may contain data considered sensitive and its content should be reviewed by the originating organization before being passed to any third party. No changes will be made to system configuration. Press ENTER to continue, or CTRL-C to quit. Please enter the case id that you are generating this report for []: Setting up archive ... Setting up plugins ... Running plugins. Please wait ... Finishing plugins [Running: systemd] Finished running plugins Creating compressed archive... Your sosreport has been generated and saved in: /var/tmp/sosreport-zhufanyu-2021-01-03-zfagtvi.tar.xz The checksum is: d0697587adef8a90801c24240a5c9341 Please send this file to your support representative.