1、統計/etc/passwd檔案中預設shell不是/sbin/nologin的使用者個數,并将使用者都顯示出來
grep -v /sbin/nologin /etc/passwd | wc -l
grep -v /sbin/nologin /etc/passwd | cut -d: -f1
2、查出使用者UID最大值的使用者名、UID及shell類型
sort -t: -n -k3 /etc/passwd | cut -d: -f 1,3,7 | tail -1
cut -d: -f1,3,7 /etc/passwd |sort -t: -k2 -n | tail -1
ss -nt | awk -F'[: ]+' '/ESTAB/{ip[$(NF-2)]++}END{for(i in ip){print i,ip[i]}}' | sort -k2 -nr
#!/bin/bash
if [ $# -ne 1 ]; then
echo "Usage: $0 USERNAME "
exit
fi
if [ $UID -ne 0 ]; then
echo "Permission denied,please run this script with root"
exit
fi
grep -w $1 /etc/passwd > /dev/null
if [ $? -ne 0 ];then
useradd $1
echo "Add new user $1 succeeful"
echo "The infomation of new user is `id $1`"
else
echo "User $1 is already exist"
fi
autocmd BufNewFile *.sh exec ":call SetTitle()"
func SetTitle()
if expand("%:e") == 'sh'
call setline(1,"#!/bin/bash")
call setline(2,"#")
call setline(3,"#********************************************************************")
call setline(4,"#Author: Example")
call setline(5,"#Mail: [email protected]")
call setline(6,"#Version: 1.0")
call setline(7,"#Date: ".strftime("%Y-%m-%d"))
call setline(8,"#FileName: ".expand("%"))
call setline(9,"#Description: It's is test script.")
call setline(10,"#Copyright (C): ".strftime("%Y")." All rights reserved")
call setline(11,"#********************************************************************")
call setline(12,"")
endif
endfunc