[Share Experiences] linux关闭不必要的用户
Tofloor
poster avatar
蔚蓝的天空
deepin
2022-01-08 04:08
Author

#!/bin/bash
for user in $( cat /etc/passwd | grep -v root | cut -d ":" -f 1 )
do
str=(adm lp sync shutdown halt news uucp operator games gopher)
str=(adm lp news uucp games dip pppusers popusers slipusers)
for i in ${str[*]}
do
if [[ ​i =~ user ]]
then
#userdel -r $i
#锁定用户
usermod -L $i
#解锁
#usermod -U $i
#groupdel $i
break
fi
done
done

Reply Favorite View the author
All Replies
deepin-mq
deepin
2022-01-08 04:48
#1

感谢分享

Reply View the author
jjcui8595
deepin
2022-01-08 14:50
#2

谢谢,我试试

Reply View the author
waiting
deepin
2022-01-12 19:29
#3

格式化代码

#!/bin/bash
for user in $( cat /etc/passwd | grep -v root | cut -d ":" -f 1 ); do
  str=(adm lp sync shutdown halt news uucp operator games gopher)
  str=(adm lp news uucp games dip pppusers popusers slipusers)
  for i in ${str[*]}; do
    if [[ i= user ]]; then
      # userdel -r $i
      #锁定用户
      usermod -L $i
      #解锁
      # usermod -U $i
      # groupdel $i
      break
    fi
  done
done


Reply View the author