1、找出ifconfig “网卡名” 命令结果中本机的IPv4地址
[root@rocky-8 ~]# ifconfig |head -n+2 |tail -1 | cut -d ' ' -f 10
192.168.44.18
2、查出分区空间使用率的最大百分比值。
[root@rocky-8 ~]# df |cut -b 48-50 | tail -n +2 |sort -n -r |head -n 1
22
[root@rocky-8 ~]#
3、查出用户UID最大值的用户名、UID及shell类型
root: x: 0: 0: root: /root: /bin/bash
用户名:口令:用户标识号:组标识号:注释性描述:主目录:登录Shell
[root@rocky-8 ~]# cat /etc/passwd |cut -d : -f 1,3,7 |sort -t: -nk2 -r |head -n 1
nobody:65534:/sbin/nologin
4、查出/tmp的权限,以数字方式显示
root@ubuntu2004:~# stat /tmp |head -n +4|tail -1 |cut -d' ' -f2
(1777/drwxrwxrwt)
root@ubuntu2004:~# stat /tmp |head -n +4|tail -1 |cut -d' ' -f2|cut -b 2-5
1777
root@ubuntu2004:~#
5、统计当前连接本机的每个远程主机IP的连接数,并按从大到小排序
[root@rocky-8 ~]# ss -nut
Netid State Recv-Q Send-Q Local Address:Port Peer Address:Port Process
tcp ESTAB 0 0 192.168.44.18:22 192.168.44.1:61269
tcp ESTAB 0 0 192.168.44.18:22 192.168.44.28:60844
tcp ESTAB 0 0 192.168.44.18:22 192.168.44.1:61021
tcp ESTAB 0 36 192.168.44.18:22 192.168.44.1:56595
[root@rocky-8 ~]# ss -nut | tr -s ' '
Netid State Recv-Q Send-Q Local Address:Port Peer Address:Port Process
tcp ESTAB 0 0 192.168.44.18:22 192.168.44.1:61269
tcp ESTAB 0 0 192.168.44.18:22 192.168.44.28:60844
tcp ESTAB 0 0 192.168.44.18:22 192.168.44.1:61021
tcp ESTAB 0 36 192.168.44.18:22 192.168.44.1:56595
[root@rocky-8 ~]#
[root@rocky-8 ~]# ss -nut | tr -s ' ' |cut -d ' ' -f6| cut -d : -f1 | tail -n +2 |sort -r
192.168.44.28
192.168.44.1
192.168.44.1
192.168.44.1