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.

    • Related Articles

    • How to mass rename users?

      Mass renaming of users There could be a need to rename several users if you may not have initially created the usernames as per the recommended scheme. These processes will rename the user accounts as well as their home directories. Exercise extreme ...
    • Can I have custom user logins instead of the default student and teacher login accounts?

      This is particularly useful at the beginning of the school year or when the My sCool Server is being deployed for the first time or when mass accounts need to be created for conducting examinations. We can help you do that if you provide us the ...
    • What is the recommended scheme for student account creation?

      The My sCool Server facilitates continuity in learning. Thus, it is strongly recommended that student accounts should be created first time when they access the computer lab and deleted only once they have passed out of school. This ensures that they ...
    • Does the factory restore feature restore all user data?

      No, as the name “factory restore” suggests, it is designed to restore only the system state to a state when the server left the factory. However, user data is not deleted or modified by this process, so if the data is still on the disk then it would ...
    • Does the recovery media creation feature backup all user data?

      No, the automated server recovery mechanism is not designed for that purpose. However, it can be performed manually by following the tips given in the Backup and Recovery section in the user manual.  We also provide assistance services at a small ...