1, the statistics of / etc / passwd file shell non-default number of users / sbin / nologin, and users are displayed
cat /etc/passwd | grep -v '\/sbin\/nologin$' | wc -l
cat /etc/passwd | grep -v '\/sbin\/nologin$' | cut -d':' -f1
2, the user name of the user to detect the maximum UID, UID and shell type
cat /etc/passwd | sort -nr -t':' -k3 | head -1 | cut -d':' -f1,3,7 | tr ':' ' '
3, connected to the current connection statistics for each remote host IP of the machine, press descending order
ss -an | tr -s ' ' | cut -d' ' -f6 | sed -rn '/[0-9]+\:[0-9]+$/p' | cut -d':' -f1 | sort | uniq -c | sort -rn
4, scripting createuser.sh, achieve the following functions: using a user name as a parameter, if the user specifies parameters exists to show its presence, or add it; display information to add user id number, etc.
vim createuser.sh
read -p "Please enter username: " UserName
id $UserName &> /dev/null && echo -e "\033[31mUser exist\033[0m" || useradd $UserName;cat /etc/passwd | grep $UserName
5, write a script generated script basic format, including the author, contact information, version, time, and description
vim .vimrc
autocmd BufNewFile *.py,*.cc,*.sh,*.java exec ":call SetTitle()"
func SetTitle()
if expand ("%:e") == 'sh'
call setline(1, "#!/bin/bash")
call setline(2, "#Author:Rick")
call setline(3, "#Time:".strftime("%F %T"))
call setline(4, "#Name:".expand("%"))
call setline(5, "#Version:V1.0")
call setline(6, "#Description:This is a production script.")
call setline(7, "")
endif
endfunc