Welcome to the MacNN Forums.

If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

You are here: MacNN Forums > Software - Troubleshooting and Discussion > Mac OS X > Help! Can't Delete User Account!

Help! Can't Delete User Account!
Thread Tools
OAW
Professional Poster
Join Date: May 2001
Status: Offline
Reply With Quote
Apr 7, 2003, 02:17 PM
 
I was setting up my old G4 Cube for my brother who's going to now use it as his home machine (::: sniff sniff::: ::: ... goodbye old friend! ... :::sniff sniff::. It hadn't been used in awhile, so I upgraded from OS X 10.2.1 to 10.2.4 via Software Update ... along with 10 or 12 other apps that were out of date. The machine was ready to go ... I only had one last thing to do. Namely, get rid of my user account and replace it with one for my brother. At first I tried to rename my account .... but that wasn't allowed. So I then created an admin user account for my brother, and then attempted to delete my account. I was signed into the new admin account for my brother ... selected my account in the "Accounts" system preference ... clicked delete ... and nothing happened. Actually, the system did create a disk image of the contents of my Home folder and placed it in a "/Users/Deleted Users/" directory. But the user account remained in the Account list. I logged out and my user account was still on the login window. I rebooted and it was still there on the login window. I shut down, waited, and booted and it was still there on the login window.

I then logged into my account, and attempted to delete the newly created account for my brother. Same result. Successful creation of the home folder disk image ... but no deletion of the user account itself.,

I then enabled the root user and logged in as root (I know I know ... I'm not supposed to go there ... but I was running out of options) .... and attempted to delete my user account. Same result!

I then re-downloaded all 77 MB of the OS X 10.2.4 update and reinstalled the OS. Again I tried to delete my user account, and again I got the same result. BTW, it would be nice if Software Update had an option to store the actuall install package rather than just a receipt packgage so you don't have to re-download if you ever need to re-install! But I digress ....

At that point I gave up and just let him have the Cube with my old account on it. It's ugly having my account in the login window ... but everything else "appears" to be working correctly. So today I thought I'd come here for help.

Just to head off any well meaning reminders of the basics ... let me state the following:

1. Whenever I tried to delete one account I was logged in as the other.

2. The account I was logged into had "admin" privileges.

3. The user account would not delete for any account I tried. Regardless of whether or not the account being deleted had "admin" privileges.

4. I've successfully added and deleted user accounts on that machine before without any problems.

So having said all that ....

Does anyone know what is going on? Any suggestions? Help!!!

OAW
     
Mac Enthusiast
Join Date: Mar 2000
Location: atx, usa
Status: Offline
Reply With Quote
Apr 7, 2003, 02:29 PM
 
i had this same problem a while ago. my experience was trying to delete a 'guest' user. i had six or so .dmg's that were created when i tried to delete the account, but it was never removed.

ultimately, i went into the netinfo manager and deleted the user from the netinfo database and then deleted the user directory via the terminal.

i tried a bunch of other stuff w/o success. if you're squemish about mucking with the netinfo database, i don't have an alternative. i do it fairly frequently and nothing bad has happened to me yet!

adam
     
OAW  (op)
Professional Poster
Join Date: May 2001
Status: Offline
Reply With Quote
Apr 7, 2003, 02:39 PM
 
Originally posted by adamk:
i had this same problem a while ago. my experience was trying to delete a 'guest' user. i had six or so .dmg's that were created when i tried to delete the account, but it was never removed.

ultimately, i went into the netinfo manager and deleted the user from the netinfo database and then deleted the user directory via the terminal.

i tried a bunch of other stuff w/o success. if you're squemish about mucking with the netinfo database, i don't have an alternative. i do it fairly frequently and nothing bad has happened to me yet!

adam
Adam,

Thanks for the tip! I see in NetInfo that I can select a user and click the delete button. Offhand, do you know the Unix command to get rid of the home directory? (Sorry .... I don't have much of a Unix background.) Also, does this get rid of the account on the login window?

OAW
     
Dedicated MacNNer
Join Date: Dec 2002
Location: someplace
Status: Offline
Reply With Quote
Apr 7, 2003, 03:57 PM
 
Originally posted by OAW:
Thanks for the tip! I see in NetInfo that I can select a user and click the delete button. Offhand, do you know the Unix command to get rid of the home directory? (Sorry .... I don't have much of a Unix background.) Also, does this get rid of the account on the login window?
Here is a script for removing user accounts via the command line. It will remove accounts added via the Accounts System Preferences pane. It removes regular user accounts, administrative accounts, or Windows login accounts (or any combination of the three). It will also remove the user's home directory and any information about the user in /Users/Deleted Users, in case you have attempted to remove a user account via the Accounts preference pane and found it to be stubborn.

I have chosen to name the script rmuser rather than 'deluser' so there will be no confusion between Aaron Faby's scripts at Server Logistics (or others scripts on the net) and this script. Feel free to name the script 'deluser' if you find that mnemonically easier.

Note: the intention of this script is to provide:
1). user removal from the command line
2). a way to remove stubborn user accounts that cannot be removed from the GUI.
It will not (necessarily) provide a way to remove all types of user accounts created by testuser's adduser script or other adduser scripts. (It may work for that purpose, but it is not necessarily intended for that usage.) I'll leave it to other authors to create specific companion user removal script to accompany other adduser scripts.

Code:
#!/bin/sh ## # rmuser # This script will remove user accounts on OS X 10.2.x, (10.1.x untested) # author: gatorparrots <gatorparrots@mad.scientist.com> # problems or suggestions can be posted to the macfora.com OS X UNIX forum # # usage: rmuser [username] ## if [ $# -eq 0 ]; then printf "usage: rmuser [username]\n" printf "User account and homedir will be irretrievably removed.\n" >&2 exit 2 fi username=$1 if [ "$username" = "root" ]; then echo "That's not a wise thing to do." exit fi if [ -z "`niutil -read . /users/$username 2> /dev/null `" ]; then echo "$username does not exit." exit 2 fi # Need to be a sudoer to remove user sudo -p "Please authenticate to remove user (administrator password): " printf "" || { echo "Abort: could not authenticate" >&2 exit 1 } #remove configuration files and other vestiges if sudo [ -f /var/db/samba/hash/$username ]; then sudo rm -f /var/db/samba/hash/$username fi if [ -f "/etc/httpd/users/$username.conf" ]; then sudo rm -f "/etc/httpd/users/$username.conf" fi if [ -f "/Users/Deleted Users/$username.dmg" ]; then sudo rm -f "/Users/Deleted Users/$username.dmg" fi ##You may wish to retain the user's homedir; if so, comment lines below userhome="`niutil -readprop . /users/$username home`" sudo rm -rf $userhome #remove admin status, if exists sudo niutil -destroyval . /groups/admin users $username #remove user sudo niutil -destroy . /users/$username sudo niutil -resync . echo 'User account "'$username'" removed.'
     
OAW  (op)
Professional Poster
Join Date: May 2001
Status: Offline
Reply With Quote
Apr 7, 2003, 04:14 PM
 
Thanks Gatorparrots!

OAW
     
Dedicated MacNNer
Join Date: Dec 2002
Location: someplace
Status: Offline
Reply With Quote
Apr 7, 2003, 04:15 PM
 
If you're not up for shell scripting, here is an AppleScript version of the above script. (To use, simply run a Find & Replace operation in ScriptEditor on the short user name
[the example below uses dave as the example] and change to the user name to be removed):

Code:
(* This script will remove stubborn user accounts under OS X *) set runresult to "" tell me to activate display dialog "This script will completely remove the named stubborn user account." buttons {"Cancel", "Remove"} default button 2 set userchoice to button returned of result if userchoice = "Remove" then try --Remove stubborn user account set rmSamba to "sudo rm -f /var/db/samba/hash/dave ;" set rmApache to "sudo rm -f /etc/httpd/users/dave.conf ;" set rmDelUsers to "sudo rm -f '/Users/Deleted Users/dave.dmg' ;" set rmHome to "sudo rm -rf /Users/dave ;" set demote to "sudo niutil -destroyval . /groups/admin users dave ;" set rmUser to "sudo niutil -destroy . /users/dave ;" set resyncNI to "sudo niutil -resync ." do shell script rmSamba & rmApache & rmDelUsers & rmHome & demote & rmUser & resyncNI with administrator privileges do shell script "/bin/sleep 1" tell me to activate set runresult to "Stubborn user account removed" & return on error errormsj display dialog errormsj as string set runresult to runresult & "User removal failed: " & errormsj & return --return adds ASCII13 to the output end try else if userchoice = "Cancel" then end if
     
Forum Regular
Join Date: Mar 2001
Location: Sweden
Status: Offline
Reply With Quote
Apr 7, 2003, 04:34 PM
 
start from os 9, even from the os 9 cd, and delete ANYTHING you want.

that's the way I did it. Cannot boot from OS 9 - bad luck!
     
   
Thread Tools
Forum Links
Forum Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts
BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On
Top
Privacy Policy
All times are GMT -5. The time now is 11:18 PM.
All contents of these forums © 1995-2011 MacNN. All rights reserved.
Branding + Design: www.gesamtbild.com
vBulletin v.3.8.7 © 2000-2011, Jelsoft Enterprises Ltd., Content Relevant URLs by vBSEO 3.3.2