1、列出當前系統上所有已經登錄的的用戶的用戶名,注意同一用戶登錄多次,則只顯示一次
[root@keyou ~]# w -hs | cut -d' ' -f 1 | sort -u gentoo root
2、取出最后登錄到當前系統的用戶相關信息
[root@keyou ~]# useryh=$(w -h | sort -r -k 2,5 | cut -d' ' -f 1 | sed -n 2p) | grep -E "^$useryh" /etc/passwd archlinux:x:3002:3002::/home/archlinux:/bin/bash
3、取出當前系統上被用戶當作其默認shell最多的那個shell
[gentoo@keyou ~]$ cat /etc/passwd | cut -d: -f 7 | sort | uniq -c | sort -u | grep -E -o "\<..sh\>" | head -n 1 bash
4、將/etc/passwd/中的第三個字段數字最大的后10個用戶信息全部改為大寫后保存至/tmp/maxusers.txt
~]# cat /etc/passwd | sort -t: -k 3 -n -r | head -n 10 | tr [a-z] [A-Z] >/tmp/maxusers.txt
原創文章,作者:N24-zhoub,如若轉載,請注明出處:http://www.www58058.com/59178