SUDO command - How to remove a User using Terminal?

So I just inherited from my coworker's MacBook Pro. I then decided to transfer all of my files and realized that the root folder was still on his name. I changed the User's name in "System Preferences" but that did not change the root folder's name. I then went to Terminal and tried to change the folder's name using the "mv OldFoldersName NewFoldersName" and the prompt said Permission denied. I then used "sudo mv OldFoldersName NewFoldersName". After restarting my computer, all the files were gone and I landed on a "LION first time USE" type of Desktop. All my files are gone and terminal shows me two users' names under /Users/ => OldUser and NewUser.

What can I do to recover my old files? What can I do to repair my Mistake and only have one User?

Thank you very much for your help.

iMac (21.5-inch Late 2009), Mac OS X (10.7.3)

Posted on Mar 30, 2012 9:04 AM

Reply
3 replies

Mar 30, 2012 9:23 AM in response to 10Kg

I trust you already know you seriously messed things up by using sudo in the manner you have. Root is off limits for this very reason.


The painless way to transfer ownership would have been to simply log in under the old user, create a new account, log out of the old one, log into the new one, and then delete the old one. Takes about five minutes if you include making a cup of coffee.

... I then decided to transfer all of my files


Attempting to undo those actions may be possible, but why not just transfer your files again? Assuming that the source from which they originated is still available and intact, I recommend you erase your MPB, reinstall Lion, and start over.


When you reach the new account setup screen, do not create a new user - use Migration Assistant to transfer your files.


By the way if you haven't already, make sure to obtain the MBP's original system install DVDs from your coworker. They should always accompany a change of ownership.


Message was edited by: John Galt

Mar 30, 2012 9:25 AM in response to John Galt

When you reach the new account setup screen, do not create a new user - use Migration Assistant to transfer your files.


That's actually Setup Assistant at the setup screen with a fresh install of OS X as there are no Admin users on the machine to log into and use Migration Assistant program correct?


Migration Assistant moves users and doesn't delete the ones on the machine, Setup Assistant transfers the user from one machine to another with no users.*



*root user running the machine a exception as it's not enabled

Mar 30, 2012 9:32 AM in response to 10Kg

10Kg wrote:


All my files are gone and terminal shows me two users' names under /Users/ => OldUser and NewUser.


What can I do to recover my old files?


If your adapt at using Terminal, why don't you hook up a blank external drive, command s boot into Single user root mode,


ls /Users


then cd to that directory or mv it to the external drive?


Any why are you messing with Terminal and on your only copy of your files?


Kind of risky right?


Nearly everything on a Mac has been figured out and a safe GUI ability to allow users to do things, there is no need to risk the dangers of the Terminal and unknown under workings.


But now you have to revert to your backup and start all over like John said.


Read here for more options


https://discussions.apple.com/docs/DOC-3046


https://discussions.apple.com/docs/DOC-3045

This thread has been closed by the system or the community team. You may vote for any posts you find helpful, or search the Community for additional answers.

SUDO command - How to remove a User using Terminal?

Welcome to Apple Support Community
A forum where Apple customers help each other with their products. Get started with your Apple Account.