编写脚本,实现如果用户存在就提示存在,不存在就创建,并显示创建后信息

#!/bin/bash
read  -p  "Please useruname:  "  
id  $REPLY &>/dev/null 
if  [ $? -eq 0 ];then 
   echo "user $REPLY is exists."
else 
   useradd  $REPLY
   echo "$REPLY infomation: "
   getent  passwd $REPLY  
fi    

生成脚本基本格式

#!/bin/bash 
cat>$uname.sh<<EOF
#!/bin/bash 
#Time: `date +%F' '%T` 
#Author:angelo 
#Email:root@qq.com
#Version: 
#Descriprion:
EOF

查找etc目录下大于1M的普通文件

[root@centos8-smalll-2 scripts]# find /etc/  -size +1M  -type  f 
/etc/selinux/targeted/policy/policy.31
/etc/udev/hwdb.bin

获取etc所有conf结尾的文件,归档至/usr/local/src下以日期命令的文件中

tar -cvhf  /usr/local/src/`date +%F`.tar   /etc/*.conf 

查找当前系统上没有属主或属组,且最近一个周内曾被访问过的文件或目录

find   /  -nogroup -nouser  -a  -atime -7  -ls 

查找/etc目录下至少有一类用户没有执行权限的文件

find ../test/  !  -perm  -111   -a  ! -perm  -110   -a ! -perm -101  -a ! -perm -011 -ls