1、統(tǒng)計(jì)出/etc/passwd文件中其默認(rèn)shell為非/sbin/nologin的用戶個(gè)數(shù)阵具,并將用戶都顯示出來
1.grep -v "/sbin/nologin" /etc/passwd | cut -d: -f 1
2虚倒、查出用戶UID最大值的用戶名园爷、UID及shell類型
sort -t ":" -n -k3 /etc/passwd |tail -1 | cut -d: -f1,3,7
3浴骂、統(tǒng)計(jì)當(dāng)前連接本機(jī)的每個(gè)遠(yuǎn)程主機(jī)IP的連接數(shù)钱磅,并按照從大到小排序
1.第一步 基本實(shí)現(xiàn)梦裂;ss -nt | tr -s " " | cut -d " " -f5 | cut -d ":" -f1 | uniq -c | sort -nr
2.第二步:過濾掉表頭解決方案
ss -nt | grep [[:digit:]] | tr -s " " | cut -d " " -f5 | cut -d ":" -f1 | uniq -c | sort -nr
netstat -nt | grep [[:digit:]] | tr -s " " | cut -d " " -f5 | cut -d ":" -f1 | uniq -c | sort -nr
4、編寫腳本
createuser.sh续搀,?實(shí)現(xiàn)如下功能:?使用一個(gè)用戶名作為參數(shù)塞琼,如果指定參數(shù)的用戶存在,就顯示其存在禁舷,否則添加之彪杉,顯示添加的用戶的id號等信息
#!/bin/bash
if [ $# -eq 0 ];then
? ? echo "user a argument after the script name"
? ? exit
elif [ $# -gt 1 ];then
? ? echo " one arg is requed ,but $# arg was suplled"
? ? exit
fi
if id -u $1 &> /dev/null;then
? ? echo "the user has exits,peng refirm it"
else
? ? useradd $1 && echo "user $1 is created,`id $1`"
fi
5、編寫生成腳本基本格式的腳本牵咙,包括作者派近,聯(lián)系方式,版本洁桌,時(shí)間渴丸,描述等
=====================================================================
set tabstop=4
set softtabstop=4
set shiftwidth=4
set expandtab
set ignorecase
set cursorline
set autoindent
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? ? ? ? ? ? ? ? ? czq")
? ? call setline(5,"#phone? ? ? ? ? ? ? ? ? 177**********")
? ? cal? setline(6,"#Date? ? ? ? ? ? ? ? ? ".strftime("%Y-%m-%d"))
? ? endif
endfunc
autocmd BufNewFile * normal G
===================================================================================