Linux常用命令(2)—系统状态检测命令

ifconfig

获取网卡配置与网络状态等信息。ifconfig [参数][网络设备]
详细可见我的博客 IP地址、子网掩码、网关(Linux查看和配置)

1.查看
[root@hostname ~]# ifconfig

2.指定网卡关闭及开启
[root@hostname ~]# ifconfig ens160 down
[root@hostname ~]# ifconfig ens160 up

3.指定网卡修改IP地址
[root@hostname ~]# ifconfig ens160 192.168.1.1 netmask 255.255.255.0

4.指定网卡修改MAC地址
[root@hostname ~]# ifconfig ens160 hw ether xx:xx:xx:xx:xx:xx

5.指定网卡ARP协议的关开
[root@hostname ~]# ifconfig ens160  -arp
[root@hostname ~]# ifconfig ens160 arp

uname

查看系统内核版本与系统架构等信息。uname [-a]

1.查看
[root@hostname ~]# uname -a
Linux hostname.com 4.18.0-80.el8.x86_64 #1 SMP Wed Mar 13 12:02:46 UTC 2019 x86_64 x86_64 x86_64 GNU/Linux

2.查看详细信息
[root@hostname ~]# cat /etc/redhat-release 
Red Hat Enterprise Linux release 8.0 (Ootpa)

uptime

查看系统负载信息。

[root@hostname ~]# uptime
 15:14:50 up 12 min,  1 user,  load average: 0.00, 0.10, 0.14

free

显示当前内存使用量。free [-h]

[root@hostname ~]# free -h
              total        used        free      shared  buff/cache   available
Mem:          1.9Gi       1.1Gi       273Mi        14Mi       528Mi       630Mi
Swap:         2.0Gi          0B       2.0Gi
#total-总量,used-已用量,free-空闲量,shared-进程功效的内存量,buff/cache-缓存内存量,available-可用量

who

查看当前登入主机的用户终端信息。

[root@hostname ~]# who
root     tty2         2023-04-13 15:03 (tty2)
#tty2-终端设备

last

调取主机被访记录。

[root@linuxprobe ~]# last
root     tty2         tty2             Thu Apr 13 15:03   still logged in
reboot   system boot  4.18.0-80.el8.x8 Thu Apr 13 15:02   still running
root     tty2         tty2             Wed Apr 12 17:49 - crash  (21:12)
reboot   system boot  4.18.0-80.el8.x8 Wed Apr 12 17:48   still running
root     tty2         tty2             Wed Apr 12 17:02 - down   (-7:14)
toor     tty2         tty2             Wed Apr 12 16:56 - 17:01  (00:05)

ping

测试主机之间的网络连通性。ping [参数] 主机地址

1.ping域名
[root@hostname ~]# ping www.baidu.com

2.发送请求包限定为4次
[root@hostname ~]# ping -c 4 www.baidu.com 

3.发送3次请求包,间隔0.2s,最长等待时间3s
[root@hostname ~]# ping -c 3 -i 0.2 -W 3 www.baidu.com 

netstate

显示网络连接、路由表、接口状态等网络相关信息。nice [参数]

1.路由表
[root@hostname ~]# netstat -r
Kernel IP routing table
Destination     Gateway         Genmask         Flags   MSS Window  irtt Iface
192.168.122.0   0.0.0.0         255.255.255.0   U         0 0          0 virbr0

2.网卡列表
[root@hostname ~]# netstat -i
Kernel Interface table
Iface             MTU    RX-OK RX-ERR RX-DRP RX-OVR    TX-OK TX-ERR TX-DRP TX-OVR Flg
ens160           1500        6      0      0 0             0      0      0      0 BMRU
lo              65536       36      0      0 0            36      0      0      0 LRU
virbr0           1500        0      0      0 0             0      0      0      0 BMU

history

显示执行的命令历史。history [-c]

1.查看
[root@linuxprobe ~]# history 
    1  ls
    2  cd Desktop/
    3  ls
    4  ll
    5  man
    6  man man
    7  echo hello
2.清空
[root@linuxprobe ~]# history -c
#具体保存在 ~./bash_history,不会被history -c清空

sosreport

收集系统配置及架构信息并输出诊断文档。

[root@hostname ~]# sosreport
........................................
Your sosreport has been generated and saved in:
  /var/tmp/sosreport-hostname-2023-04-13-qnunbnq.tar.xz
..........................................................

参考

《Linux就该这么学》

猜你喜欢

转载自blog.csdn.net/weixin_47505548/article/details/130149292