1、 统计出/etc/passwd文件中其默认shell为非/sbin/nologin的用户个数,并将用户都显示出来
getent passwd|cut -d':' -f1,7|grep -v /sbin/nologin|uniq -c
第四周作业
2、查出用户UID最大值的用户名、UID及shell类型
cat /etc/passwd|cut -d':' -f1,3,7|sort -t: -k2 -nr|head -n1
第四周作业
3、统计当前连接本机的每个远程主机IP的连接数,并按从大到小排序
netstat -nt|tr -s ' ' ':'|cut -d':' -f6|grep '[0-9]'|sort|uniq -c|sort -nr
第四周作业
4、编写脚本 createuser.sh,实现如下功能:使用一个用户名做为参数,如果 指定参数的用户存在,就显示其存在,否则添加之;显示添加的用户的id号等 信息
[ $# -eq 0 ] && echo "Usage:basename $0 USERNAME " && exit 0
id $1 &> /dev/null && echo "user $1 is exist" && exit 0
useradd $1 &> /dev/null && echo "user $1 is created" && echo "id $1" || { echo " Error! " ; exit 0; }
第四周作业
第四周作业

5、编写生成脚本基本格式的脚本,包括作者,联系方式,版本,时间,描述等

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: changyu")
call setline(5,"#QQ: 1258620503")
call setline(6,"#Date: ".strftime("%Y-%m-%d"))
call setline(7,"#FileName: ".expand("%"))
call setline(8,"#Description: The test script")
call setline(9,"#Copyright (C): ".strftime("%Y")." All rights reserved")
call setline(10,"#****")
call setline(11,"")
endif
endfunc
autocmd BufNewFile * normal G
第四周作业

  • 版权声明:文章来源于网络采集,版权归原创者所有,均已注明来源,如未注明可能来源未知,如有侵权请联系管理员删除。

发表回复

后才能评论