I'm writing a bash script that deletes users that are not permitted within the system, but im running into a problem.
#!/bin/bash
getent passwd {1000..60000} | cut -d: -f1 > allusers.txt;
diff allowedusers.txt allusers.txt > del.user;
for user in "cat del.user";
do userdel -r $user;
done
When I run it, everything goes smoothly until the userdel
command. It just outputs usage of userdel
.
Usage: userdel [options] LOGIN
Options:
-f, --force force removal of files,
even if not owned by user
-h, --help display this help message and exit
-r, --remove remove home directory and mail spool
-R, --root CHROOT_DIR directory to chroot into
-Z, --selinux-user remove any SELinux user mapping for the user
No changes are made to users after the script has run. Any help would be appreciated.