1、編寫腳本 createuser.sh,實現如下功能:使用一個用戶名做為參數,如果 指定參數的用戶存在,就顯示其存在,否則添加之;顯示添加的用戶的id號等信息
NAME=meng;id NAME" is exist || useradd"$NAME"
2、編寫生成腳本基本格式的腳本,包括作者,聯系方式,版本,時間,描述等
vim .vimrc
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: mengbixiao")
call setline(5,"#QQ: 25891783")
call setline(6,"#Date: ".strftime("%Y-%m-%d"))
call setline(7,"#FileName: ".expand("%"))
call setline(8,"#URL: https://blog.51cto.com/13931555")
call setline(9,"#Description: The test script")
call setline(10,"#Copyright (C): ".strftime("%Y")." All rights reserved")
call setline(11,"#********************************************************************")
call setline(12,"")
endif
endfunc
autocmd BufNewFile * normal G
~
3、查找/etc目錄下大于1M且類型為普通文件的所有文件
find /etc/ -size +1M -type f
4、打包/etc/目錄下面所有conf結尾的文件,壓縮包名稱為當天的時間,并拷貝到/usr/local/src目錄備份。
find /etc/ -name "*.conf" | xargs tar zcvf /data/date +%F_%T.tar.gz
5、查找當前系統(tǒng)上沒有屬主或屬組,且最近一個周內曾被訪問過的文件或目錄
find / ( -nouser -nogroup ) -atime -8 -ls
6、查找/etc目錄下至少有一類用戶沒有執(zhí)行權限的文件
find /etc ! -perm -111 -ls