Author Topic: Bulk user deletion on an xserve??  (Read 7620 times)

0 Members and 2 Guests are viewing this topic.

Offline Stephen

  • Board Veteran
  • *****
  • Posts: 5996
  • Gender: Male
    • Banbridge Academy Online
  • Speciality: Black Neck sixth Dan - No Kan Do
Bulk user deletion on an xserve??
« on: January 30, 2013, 11:01:33 AM »
I need to get rid of a couple of years of users off my xserve. So I went to the user home directory (basically the cd command so to move to a raid called raiddrive and the subfolder user_homes the command is cd /volumes/raiddrive/user_homes) in terminal and did

 ls -l >usermac.txt

This gave me a directory listing of all user home folders. I took this file and copied and pasted into excel.
Using =right(A2,Len(A2)-91)  where A2 is the first line in the directory listing gave me the short username for that user. This I copied down to the end of the userlist.

As I used c2k usernames for the short name I used web provisioning to generate a full c2k user list.

I then compared the mac user list to the c2k user list to find which users needed deleting, remeber to check for visiting students etc.

Is there anyway to batch delete the users from the workgroup manager by just knowing their user shortnames?

I was thinking of moving the user home folder from home to deletedusers folder and then backing the deleted users up before deletion.
You can do this a user at a time using sudo mv username /volumes/raiddrive/deletedusers/username

How would I do this for multiple users as I dont want to use sudo for every user.


Update:
Ok for moving a users home folder I am now trying

                            echo "password" ? sudo -S mv /volumes/raiddrive/user_homes/username123 /volumes/raiddrive/deletedusers/username123

sudo -S accepts the previously echoed password then it is a case of moving the users folder to where I am going to back it up. Then using excel and concatenate to do this for all the users I will be deleteing, quick copy and paste into a text file. Now just getting the mac to run it. I am going to try two different methods and lets you know how it goes.

Easy peasy:- took the list saved it as a text file and copied it into my user home folder. changed the file extension to .sh from .txt
Used the command  chmod +x filename.sh     where filename.sh is my file of "batch" commands

then cant remember wether I used ./filename.sh to run the file or run"./filename.sh" but ran it and all the user folders have been moved to the deletedusers folder.

So just the backup of Deleted users before actually deleting and then it is down to how do you bulk delete the users from workgroup manager.
« Last Edit: January 30, 2013, 02:33:56 PM by Stephen »
One looks back with appreciation to the brilliant teachers, but with gratitude to those who touched our human feelings. The curriculum is so much necessary raw material, but warmth is the vital element for the growing plant and for the soul of the child.
Carl Jung

Offline Si

  • C2k Gimp
  • Moderator
  • Board Veteran
  • *****
  • Posts: 4347
  • Gender: Male
  • Speciality: thinking about working
Re: Bulk user deletion on an xserve??
« Reply #1 on: January 30, 2013, 01:44:50 PM »
Good luck! Going to need to do this next year so I might be using this later.

Offline Stephen

  • Board Veteran
  • *****
  • Posts: 5996
  • Gender: Male
    • Banbridge Academy Online
  • Speciality: Black Neck sixth Dan - No Kan Do
Re: Bulk user deletion on an xserve??
« Reply #2 on: January 30, 2013, 02:30:03 PM »
The thing is si to make a distinction in a field to make the lookup easier.

e.g. have a field in the user account that is basically in2007 etc, would make the delete from Workgroup manager easier - I think.

One looks back with appreciation to the brilliant teachers, but with gratitude to those who touched our human feelings. The curriculum is so much necessary raw material, but warmth is the vital element for the growing plant and for the soul of the child.
Carl Jung

Offline Si

  • C2k Gimp
  • Moderator
  • Board Veteran
  • *****
  • Posts: 4347
  • Gender: Male
  • Speciality: thinking about working
Re: Bulk user deletion on an xserve??
« Reply #3 on: January 30, 2013, 04:25:07 PM »
I have my pupils all assigned to a year so it should be easy to delete all with the year 14 group applying to them then?

Offline Si

  • C2k Gimp
  • Moderator
  • Board Veteran
  • *****
  • Posts: 4347
  • Gender: Male
  • Speciality: thinking about working
Re: Bulk user deletion on an xserve??
« Reply #4 on: January 30, 2013, 04:27:36 PM »
By the way, the server app probably works differently - you can select users the same way as you can files with it.  select year group, Shift click the list of names and choose 'delete user' .  I think anyway...

Offline Stephen

  • Board Veteran
  • *****
  • Posts: 5996
  • Gender: Male
    • Banbridge Academy Online
  • Speciality: Black Neck sixth Dan - No Kan Do
Re: Bulk user deletion on an xserve??
« Reply #5 on: January 31, 2013, 09:08:16 AM »
My original list of users was put in as one clump with nothing to differentiate between them.

By the way make sure you dont move admin accounts when you move old users out as your admin usernames will not be part of the c2k list.
One looks back with appreciation to the brilliant teachers, but with gratitude to those who touched our human feelings. The curriculum is so much necessary raw material, but warmth is the vital element for the growing plant and for the soul of the child.
Carl Jung