主要介绍ifconfig、uname、uptime、free、who、last、histroy、sosreport命令
ifconfig
格式:ifconfig [网络设备] [参数]
作用:获取网卡配置与网络状态等信息
[root@localhost ~]# ifconfig
ens33: flags=4163<UP,BROADCAST,RUNNING,MULTICAST> mtu 1500
ether 00:0c:29:1f:0f:f7 txqueuelen 1000 (Ethernet)
RX packets 28 bytes 1680 (1.6 KiB)
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
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 1 (Local Loopback)
RX packets 260 bytes 22100 (21.5 KiB)
RX errors 0 dropped 0 overruns 0 frame 0
TX packets 260 bytes 22100 (21.5 KiB)
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 52:54:00:f7:6b:be txqueuelen 1000 (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
虚机原因与实机有差别
主要关注inet后面的IP地址,ether后面的网卡物理地址(MAC地址),RX、TX的接受数据包与发送数据包的个数与累计流量
uname
格式:uname [-a]
作用:查看系统内核与系统版本等信息
[root@localhost ~]# uname -a
Linux localhost.localdomain 3.10.0-514.el7.x86_64 #1 SMP Wed Oct 19 11:24:13 EDT 2016 x86_64 x86_64 x86_64 GNU/Linux
uptime
格式:uptime
作用:查看系统的负载时间
[root@localhost ~]# uptime
05:17:48 up 11 min, 2 users, load average: 0.00, 0.12, 0.15
显示当前系统时间、系统已运行时间、启动终端数量以及平均负载值等信息(最近1min、5min、15min的压力,最好不要长期超过1,生产环境不要超过5)。
free
格式:free [-h]
作用:显示当前系统中内存的使用量信息
[root@localhost ~]# free -h
total used free shared buff/cache available
Mem: 1.8G 517M 828M 10M 477M 1.1G
Swap: 2.0G 0B 2.0G
total | used | free | shared |
---|---|---|---|
内存总量 | 已用量 | 可用量 | 进程共享的内存量 |
who
格式:who [参数]
作用:查看当前登入主机的用户信息
[root@localhost ~]# who
root :0 2019-11-05 05:07 (:0)
root pts/0 2019-11-05 05:10 (:0)
last
格式:last [参数]
作用:查看所有系统的登陆记录
[root@localhost ~]# last
root pts/0 :0 Tue Nov 5 05:10 still logged in
root :0 :0 Tue Nov 5 05:07 still logged in
(unknown :0 :0 Tue Nov 5 05:07 - 05:07 (00:00)
reboot system boot 3.10.0-514.el7.x Tue Nov 5 05:06 - 05:26 (00:19)
root pts/0 :0 Mon Nov 4 04:43 - 22:00 (-6:-42)
root :0 :0 Mon Nov 4 04:42 - 22:00 (-6:-42)
(unknown :0 :0 Mon Nov 4 04:42 - 04:42 (00:00)
zhanglei pts/0 :0 Mon Nov 4 04:31 - 04:42 (00:11)
zhanglei :0 :0 Mon Nov 4 04:30 - 04:42 (00:11)
(unknown :0 :0 Mon Nov 4 04:30 - 04:30 (00:00)
reboot system boot 3.10.0-514.el7.x Mon Nov 4 04:29 - 22:03 (-6:-26)
zhanglei pts/0 :0 Sun Nov 3 21:03 - 21:03 (00:00)
zhanglei :0 :0 Sun Nov 3 21:02 - 21:03 (00:01)
(unknown :0 :0 Sun Nov 3 21:01 - 21:02 (00:00)
reboot system boot 3.10.0-514.el7.x Sun Nov 3 21:00 - 22:03 (01:02)
wtmp begins Sun Nov 3 21:00:36 2019
由于这些信息是以日志形式保存,很容易对其篡改,所以不要单纯以此命令作为参考。
history
格式:history [-c]
作用:用于显示历史执行过的命令
可用 [!编码数字] 来重复某一次命令
[root@localhost ~]# history
1 date
2 date -s "20191103 20:43:00"
3 date "+%Y-&m-%d %H:%M:%S"
4 date "+%Y-&M-%d %H:%M:%S"
5 date "+%Y-%M-%d %H:%M:%S"
6 date "+%Y-%m-%d %H:%M:%S"
7 date "+%j"
8 ps
9 ps aux
10 top
11 pidof top
12 pidof md
13 ipconfig
14 ifconfig
15 uname -a
16 uptime
17 free -h
18 wgo
19 who
20 last
21 history
[root@localhost ~]# !19
who
root :0 2019-11-05 05:07 (:0)
root pts/0 2019-11-05 05:10 (:0)
清空命令历史记录信息可执行:history -c
[root@localhost ~]# history -c
[root@localhost ~]# history
1 history
sosreport
格式:sosreport
作用:收集系统配置及架构信息并输出诊断文档