There could be a need to delete several users and their data quickly when students graduate and pass out of the school or after assessments are conducted and the temporary accounts created for the assessments need to be cleaned.
Herein are multiple ways in which the mass user deletion can be achieved depending on your situation.
One can write a bash script to mass delete users that have a common pattern. For example if you want to delete users test1 to test99.
Login as mssadmin and execute the following in a terminal:
- sudo su -
- for i in {1..99}; do userdel -r test$i; done
Do note that the trick is partially in identifying the pattern in the usernames, if any else more complex steps may need to be adopted which is outside the scope herein.
Delete usernames without a specific pattern
Install the mass user deletion feature