Mass user deletion on the My sCool Server

How to mass delete users?

Mass deletion of users

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.
These processes will remove the user accounts as well as their home directories i.e. all data.
Exercise extreme caution while using such automation / mass deletion scripts.
Herein are multiple ways in which the mass user deletion can be achieved depending on your situation.

Delete users with a pattern in the username

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:

  1. sudo su -
  2. 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

MSS 2.0 users should directly proceed to the Mass delete users step given below as this feature is pre-installed.
  1. Login as mssadmin into the MSS server via Remmina
  2. Ensure that the MSS is connected to the Internet and execute the below commands in a Terminal
  1. sudo su -
  2. mssupdate https://repo.myscoolserver.com/fixes/ 20220211-massuserdel
  3. recovery.sh create

Mass delete users

  1. Login as mssadmin into the MSS server via Remmina
  2. Create a text file with all the usernames to be deleted. The usernames should each be on a new line or should be space separated.
  1. sudo massuserdel 
  1. The above command shall guide with the usage instructions and how to use the file containing the usernames. Thereafter, follow the usage instructions.