How do you change your UID in OS X Mountain Lion
kimvais @ kimvais ~ $ id
uid=501(kimvais) gid=20(staff) groups=20(staff),404(com.apple.sharepoint.group.3),405(com.apple.sharepoint.group.4),502(com.apple.local.ard_reports),503(com.apple.local.ard_interact),500(com.apple.access_ssh),501(com.apple.local.ard_admin),401(com.apple.access_screensharing),402(com.apple.sharepoint.group.1),403(com.apple.sharepoint.group.2),12(everyone),33(_appstore),61(localaccounts),79(_appserverusr),80(admin),81(_appserveradm),98(_lpadmin),100(_lpoperator),204(_developer),504(com.apple.local.ard_manage),506(access_bpf),406(com.apple.sharepoint.group.5)
How do I change the 501
to something different give by my IT (so that my NFS mounts have correct UIDS) without breaking my system. Changing all the file ownerships I can handle "manually".
Solution 1:
First, I have to say that doing this is using a sledgehammer to crack a peanut but here it is.
You will want to change your userid then you will want to change the owner of all your files. You don't want to be logged on as yourself when you do this.
sudo dscl . -change /Users/YourUserName UniqueID 501 1001
is indeed the correct way to do it.
Then :-
sudo find / -uid 501 -exec chown 1001 {} \;
To change the ownership of all your files. This should stop almost all of the breakages inherent in doing this.
I assume there is some perfectly good reason for you not to be using ITs Active Directory or LDAP server to log on to your Mac and avoid all of this problem. This is the accepted way of getting around all these problems, not to mention you will then already be authenticated making mounting the NFS shares easier. Once you've done a network login you can shift your documents from the old local account to the new network account and life is hunky dory.
Solution 2:
You want to use dscl (directory service command line):
sudo dscl . -change /Users/YourUserName UniqueID 501 1001
Replace YourUserName
with (well, you know)... and, 1001
with the desired UID.
Be careful that you are not logged in as YourUserName when you run the commands.