4
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".

2

6 Answers 6

11

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.

3
  • 4
    Use 'chown -h', otherwise the symbolic links will retain their old ownership.
    – mahboudz
    Dec 31, 2014 at 5:01
  • 2
    Tony, i think it is worth mentioning that the UID 1000 seems to be somehow reserved by Mac OS: i have experimentally discovered that if i use 1000 (instead of 1001), then i will not see the user in the login window menu. I didn't notice other problems with UID 1000 though, but i switched quickly back to 1001.
    – Alexey
    Aug 29, 2016 at 12:53
  • 1
    In case anyone is wondering the above dscl command changes the UID from 501 to 1001 (it's not the Group ID).
    – Pierz
    Mar 1, 2021 at 10:06
3

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.

0

Go to System Preferences->Users & Groups->Unlock the pane->Right-click on the user you want to change->Choose "Advanced Options...".

You can change some advanced user related preferences there, BUT I DO NOT RECOMMEND IT. YOU WILL BREAK THINGS!

1
  • Are you really ready to bet on it?
    – Alexey
    Aug 29, 2016 at 8:42
0

The solutions above work well for changing the uid; however you need to be a little more careful with changing ownership of the files. Mac (and PC) users tend to use spaces and other naughty characters in filenames so you can't rely on unix to "do the right thing" all the time. This works better IMHO:

find / -uid 501 -print | while read file; do chown 1000 "$file"; done

It is regrettably slower but has the advantage of not being tripped up by spaces and other non-unix filename characters.

2
  • If you use find with -exec it will handle any special characters. May 28, 2014 at 15:36
  • Use 'chown -h' in order to change the ownership of symbolic links.
    – mahboudz
    Dec 31, 2014 at 5:01
-1

I had installed Debian Linux on my mac, and wanted the ownership of the files on my macOS to be the same as that on Debian so I wouldn't have problems accessing them from Debian. This worked for me to change my uid from 501 to 1000, and didn't break anything(default UID under debian is 1000). With one change: under macOS 10.4.11 find doesn't recognize -uid use -user instead.

1
  • The OP is asking "how"; your answer seems to say that an unspecified "how" does work, without giving details of what to do.
    – John N
    Feb 25, 2017 at 8:07
-1

Recent macOS does not allow chown, even sudo. Using recovery mode, you should mount the data APFS Data Volume (using disk utility) and then using the terminal, perform chmod -R on .../Data/Users/YourUserName.

2
  • This currently reads more like a comment to one of the existing answers than an answer on its own. Can you edit in the details required to make it complete?
    – nohillside
    Dec 28, 2023 at 9:02
  • Also, not sure about your claim here. I had no problem running sudo chown on a user directory in /Users.
    – nohillside
    Dec 29, 2023 at 10:00

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .