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.