1、编写脚本/bin/per.sh,判断当前用户对指定参数文件,是否不可读并且不可写
#!/bin/bash
read -p "please input PATH" path
[ -f $path ] || { echo $path file does not exist;exit;}
if [ ! -w $path -a ! -r $path ] ;then
echo "$path not read write"
else echo "$path read or write"ca
fi
2、便捷脚本/root/bin/excute.sh,判断参数文件是否为sh后缀的普通文件,如果是,添加所有人可执行权限,否则提供为非脚本文件
#!/bin/bash
[ -f $1 ]||{ echo $1 file does not exist or $1 not 常规文件;exit;}
if [[ $1 =~ .*sh$ ]];then
chmod u+x $1
echo "$1 +x Add success"
else echo "$1 type not is sh file"
fi
3、编写脚本/root/bin/nologin.sh和login.sh,实现禁止和允许普通用户登录系统
#!/bin/bash
read -p "1:允许普通用户登录 2:不允许普通用户登录 :" a
if [[ "$a" =~ ^\<[12]\>$ ]];then
case $a in
1)
if [ -a /etc/nologin ];then
rm /etc/nologin
echo "Allow users to login"
else echo "Allow users t