I have an expanding network and while I have the long term goal of eventually implementing Active Directory hosted on a QNAP NAS. However, in the meantime I have the issue of where my MacOS machines have one set of UIDs for the 2 or 3 users I use while my Linux machine have another.

I learned that in Mojave you need to use dscl to change attributes like UID but I am not sure how I can set the UID scheme for new users to make the new Unix and MacOS accounts more easily line up going forward. While I envision Active Directory making this moot once its in place, I presume I must get my LANs UIDs and GUIDs under control first. Aside from doing all of this manually by using tools like find and chown manually, are there tools for migrating to AD where normalizing UIDs for the same users across different hosts can be better automated and a reliable process with less risk of breakage? If not, I am pretty sure I know what I need to do and it will be gritting my teeth, but at least I know what it's going to take. If you have any suggestions that might make this easier and less dangerous please share your thoughts! For instance, I presume that no user should have it's UID changed while logged in, yes? Anwyay I welcome all thoughts and ideas!

  • The solution to this problem is called. LDAP – Allan Feb 23 at 21:22

I used this procedure to change uid's on macOS Tiger and Ubuntu. The info on passwords has changed.

Ok, so how can I check my UID? I've heard that it's dangerous to change the UID, so how should I do if I want the permissions to work in both OSes?

You can change the permissions of files and directories in either OS.

I suggest that you make a complete backup of your system. You should create a second administrator account from which you use to change your original account. You should log out your original account before proceeding.

Mac OS X ... harddrive -> Applications -> Utilities -> terminal

Ubuntu ... Applications > Accessories > Terminal or where ever the Terminal is today.

Your current user is: echo $USER Let's assume myuser

To find out your UID and GID do:

ls -ln
ls -l

Or, you can use the id command.


compare the output and write down what you find.

You best use the numeric value for your userid. In this case it is 500. To list all the files owned by a userid do:

sudo find / -user 500 -exec ls {} \;

adding a -x before the / limits the search to the current file system.

You need to adjust the uid and gid in your account definition.

In the Ubuntu terminal,

man 5 passwd  

... will give you the format of the passwd file.

sudo nano /etc/passwd

... the format is user-name, password, uid, gid, ...

control-o ... to save control-x ... to quit

The groups are defined in /etc/group

cat /etc/group

Now change the UID and GID of all files: You best use the numeric value for your userid. In this case it is 500.

sudo find / -user 500 -exec chown 1100:211 {} \;

/* Where chown has the format of chown uid:gid file-name */
/* adding -print before -exec lists the files that will be changed. */
/* You may want to leave off :211 if your uid & gid are not paired. */
/* Notice the -exec runs another command on the found file. */

sudo find / -group 20 -exec chgrp 211 {} \;

On the Mac you get into single user mode by holding down command-s when you poweron your machine. Just in case you run into problems.

On Mac OS, there are a few files that have the old uid as part of their name. The .Trashes file will be used on removal media. Here are other directories.


You will need to look on the external drives. All the trash is in a common folder with uid based subfolders. You can use the find command to do a search:

find -x /  -iname "*500*" 

Be patient. You can quit this command with a control-c

It similar in Linux, but based on the short user name.

On Linux, there are a few files that have the old user short name as part of their file and folder names.

Should some of the files be locked on macOS, you will need to unlock them. See – Darf Nader comments below. The macOS lock flag corresponds to the Unix layer uchg flag.

#To display flags:
ls -lO <filename>
#Turn off the lock:
sudo chflags nouchg 

Here is another explanation of the procedure. ( It misses some files because the author checks only the most likely places. http://lissot.net/netinfo/change_user.html


  • I should have thanked you earlier as this was the core of the process I used. The only thing this doesn't addressed were locked and needed chflags to unlock them. Unlocked, I could chown them and then set them back to their previous locked state to maintain fidelity aside from UID. The critical part to this was capturing all find output to file and then using grep incantations upon the resultant file list for specific types of outliers and dealing with them. Without this discreet file list I surely would have bungled the whole thing. One month later there's no apparent fallout! Phew. – Darf Nader Mar 23 at 2:11
  • Thanks for the report. – historystamp Mar 24 at 0:11
  • One thing I forgot to report was that I needed to boot in recovery mode to use chflgs! Have you come across this? – Darf Nader Apr 9 at 3:32
  • @Darf Nader Did booting into single user mode not work? I think recovery mode and single user mode are about the same, so whatever method you choose is good. – historystamp Apr 9 at 19:18
  • I am not sure. IIRC, the reason for this is because the changes that you need to make with chflgs cannot be performed on the root volume, but I may be incorrect. You have to unlock the files, change the UID, and then lock them again. It's a bit tedious and requires that you keep a careful list of files which you can get using a find incantation if you know what flags to look for, but I just captured the file paths by greping fails from chown and chgrp pipelines and then using awk to get the clean paths. – Darf Nader Apr 9 at 20:17

You must log in to answer this question.

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