1、统计出/etc/passwd文件中其默认shell为非/sbin/nologin的用户个数,并将用户都显示出来。
[root@wjl ~]# cat -n /etc/passwd | grep -v "/sbin/nologin" | cut -d ':' -f '1' | wc -l
9
[root@wjl ~]# cat -n /etc/passwd | grep -v "/sbin/nologin" | cut -d ':' -f '1'
1 root
6 sync
7 shutdown
8 halt
38 linuxprobe
40 mandriva
41 mageia
42 slackware
43 wjl
2、查出用户UID最大值的用户名、UID及shell类型。
[root@wjl ~]# cat /etc/passwd | cut -d ':' -f '3' | sort -n | tail -n 1
65534
[root@wjl ~]# cat /etc/passwd | grep 65534 | cut -d ':'-f '1,3,7'
Nfsnobody:65534:/sbin/nologin
3、统计当前连接本机的每个远程主机IP的连接数,并按从大到小排序。
[root@wjl ~]# netstat -net | grep [[:digit:]] | tr -s " " : | cut -d: -f6 | sort | uniq -c | sed "s@^[[:space:]]\+@@" | cut -d ' '