0

Because of a full disk crash of my PowerMac (using macOS 10.9.5 (Mavericks)), I lost an account named entry: No trace of it can be found when using “System Preferences > Users and Groups,” or with terminal commands such as su my_lost_account. However, all the files are still there, with the unamed uid, in the still correctly named home directory.

Is it possible for me to create a new account with the exact same login name and UID of my lost account and assign it with the home directory that already has content that I want to keep?

Thanks in advance for any clues.

  • I'm having a hard time working out what your question is. Can you edit it to be more clear? – Blackwood May 26 '18 at 23:41
  • Is the OS X user account model pure Unix with /etc/passwd and such or is there a secondary internal mechanism at play? If just Unix-y then simply re-creatign the appropriate line in /etc/passwd and then setting a password may do... and the line may be in a older backup copy of the file at /etc/passwd- – ivanivan May 28 '18 at 4:14
0

I believe you can create a specific account without overwriting your data. But I'd strongly suggest making a copy of your data before trying.

To create a new user with a specific name and UID, use dscl from the command line:-

dscl . -create /Users/<user>
dscl . -create /Users/<user> UserShell /bin/bash 
dscl . -create /Users/<user> RealName "<real name>"
dscl . -create /Users/<user> UniqueID "<UID>"
dscl . -create /Users/<user> PrimaryGroupID "<GID>"
dscl . -create /Users/<user> NFSHomeDirectory /Users/<user>
dscl . -create /Users/<user> Password 

The final command above will ask you for a password.

e.g. for user "fred", real name "Fred Quimby", UID 501, GID 20, with home directory /Users/fred

dscl . -create /Users/fred
dscl . -create /Users/fred UserShell /bin/bash 
dscl . -create /Users/fred RealName "Fred Quimby"
dscl . -create /Users/fred UniqueID "501"
dscl . -create /Users/fred PrimaryGroupID "20"
dscl . -create /Users/fred NFSHomeDirectory /Users/fred
dscl . -create /Users/fred Password

Your Answer

By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.

Not the answer you're looking for? Browse other questions tagged or ask your own question.