1、统计出/etc/passwd 文件中其默认shell为非/sbin/nologin的用户个数,并将用户都显示出来
sed -n '/\/sbin\/nologin/p' /etc/passwd | cut -d: -f1
2、查出用户UID最大值的用户名、UID及shell类型
cat /etc/passwd | sort -n -t: -k3 | tail -1 | cut -d: -f1,3,7
3、统计当前连接本机的每个远程主机IP的连接数,并按从大到小排序
ss -t | tail -n +2 | tr -s ' ' ':' | cut -d: -f6 | sort | uniq -c
4、编写脚本createuser.sh,实现如下功能:使用一个用户名做为参数,如果指定参数的用户存在,就显示其存在,否则添加之;显示添加的用户的id号等信息
vim createuser.sh
#!/bin/bash
read -p "Please input User Name: " name
id $name&>/dev/null && echo "user is exist" || echo "user is not exist,in creating.please waiting.."
id $name&>/dev/null || useradd $name
id $name
chmod +x createuser.sh
5、编写生成脚本基本格式的脚本,包括作者,联系方式,版本,时间,描述等
set et
set ts=4
set ignorecase
set cursorline
set autoindent
autocmd BufNewFile *.sh, exec ":call SetTitle()"
let $author_name = "Daichangchun"
let $author_email = "daichangchun333@163.com"
func SetTitle()
if &filetype == 'sh'
call setline(1,"\#################################")
call append(line("."),"\#File Name: ".expand("%"))
call append(line(".")+1,"\# Author: ".$author_name)
call append(line(".")+2,"\# mail: ".$author_email)
call append(line(".")+3,"\# Created Time: ".strftime("%Y_%m_%d"))
call append(line(".")+4,"\#################################")
call append(line(".")+5,"#!/bin/bash")
call append(line(".")+6,"")
else
call setline(1,"\#################################")
call append(line("."),"\#File Name: ".expand("%"))
call append(line(".")+1,"\# Author: ".$author_name)
call append(line(".")+2,"\# mail: ".$author_email)
call append(line(".")+3,"\# Created Time: ".strftime("%c"))
call append(line(".")+4,"\#################################")
call append(line(".")+5,"#!/usr/bin/python")
call append(line(".")+6,"")
endif
endfunc