ctf线下赛中关闭非法用户shell脚本

linux中三类用户:根用户,虚拟用户,普通用户。

其中普通用户的UID一般介于500-6000之间。

#!/bin/bash
for uid in $( cat /etc/passwd | cut -d ":" -f3 )
do
if [[ $uid -gt 500 && $uid -lt 6000 ]]
then
user=$(cat /etc/passwd | grep "$uid" | cut -d ":" -f1)
echo "$user $uid"
#usermod -L $user
#usermod -U $user
#passwd -l/u $user
fi
done



原文地址:https://www.cnblogs.com/Downtime/p/7398898.html