{"id":208843,"date":"2021-01-12T08:54:06","date_gmt":"2021-01-12T00:54:06","guid":{"rendered":"https:\/\/lrxjmw.cn\/?p=208843"},"modified":"2021-01-05T09:13:01","modified_gmt":"2021-01-05T01:13:01","slug":"delete-one-multiple","status":"publish","type":"post","link":"https:\/\/lrxjmw.cn\/delete-one-multiple.html","title":{"rendered":"\u5206\u4eab\u4e00\u4e2a\u5feb\u901f\u5220\u9664\u4e00\u4e2a\u6216\u591a\u4e2a\u7528\u6237\u811a\u672c"},"content":{"rendered":"
\u5bfc\u8bfb<\/td>\n | Linux\u4e0b\u5220\u9664\u7528\u6237\u4e0d\u4ec5\u4ec5\u662fuserdel -r \u90a3\u4e48\u7b80\u5355\uff0c\u5206\u4eab\u4e00\u4e2a\u5feb\u901f\u5220\u9664\u4e00\u4e2a\u6216\u591a\u4e2a\u7528\u6237\u811a\u672c\u3002<\/strong><\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n <\/p>\n \u5982\u679c\u4f60\u5220\u9664\u7528\u6237\u65f6\uff0c\u8be5\u7528\u6237\u6709\u8bb8\u591a\u8fdb\u7a0b\u6b63\u5728\u8fdb\u884c\uff0c\u4f60\u662f\u4e0d\u662f\u8981\u4e00\u4e2a\u4e2akill\u6389\u518d\u5220\u9664\uff1b<\/p>\n \u5982\u679c\u4f60\u6210\u529f\u5220\u9664\u8be5\u7528\u6237\u540e\uff0c\u7cfb\u7edf\u4e2d\u8fd8\u6709\u9700\u8981\u6539\u7528\u6237\u7684\u6587\u4ef6\u662f\u4e0d\u662f\u8fd8\u8981\u5220\u9664\u3002<\/p>\n \u5982\u4e0a\uff0c\u5c82\u4e0d\u9ebb\u70e6\u3002\u4e0b\u9762\u7684\u811a\u672c\u53ef\u4ee5\u5e2e\u4f60\u5feb\u901f\u5220\u9664\u4e00\u4e2a\u6216\u591a\u4e2a\u7528\u6237\u3002<\/p>\n
#!\/bin\/bash\r\n#delete user from system\r\n#by slitobo 2017\/6\/2\r\n\r\n#check user is root\r\n[ `id -u` -ne 0 ] && echo \"Please change to root user ...\" && exit 10\r\n\r\n#check arguments number\r\n[ $# -lt 1 ] && echo \"Usage: $0 user1 [user2] ...\" && exit 11\r\n\r\n#use list\r\nUSER=($@)\r\n\r\nfor i in ${USER[@]}\r\ndo\r\n if id $i &> \/dev\/null;then\r\n read -n 1 -p \"Comfirm Delete User \"$i\" [y=comfirm,other key=cancel]:\" SURE\r\n case $SURE in\r\n y|Y)\r\n echo\r\n ps -u $i --no-heading | awk '{print $1}' | xargs kill -9 &> \/dev\/null #kill user pid\r\n find \/ -user $i -exec rm -rf {} \\; &> \/dev\/null #delete user files\r\n userdel $i &> \/dev\/null #delete user\r\n echo \"The user $i deleted\"\r\n ;;\r\n *)\r\n echo\r\n echo \"$i delete not successful\"\r\n ;;\r\n esac\r\n fi\r\ndone<\/pre>\n","protected":false},"excerpt":{"rendered":" |