One way to fix this is by setting loose permissions (the mode value, as in
rwxr-xr-x, or 755 in octal). Note that the permissions octal code is not the same as the UID value. In either OS, you can set the default permissions used on files with the
umask command, which specifies the bit value to be removed from file permissions. For instance,
umask 022 removes write permission for the group and other permissions, resulting in 755 (
rwxr-xr-x) permissions on new files (or 644 if something removes the execute permission bit, which is common practice for files). This is largely a command-line tool, though; if you're largely a GUI user, you'll need to find another tool to do the job, probably related to your desktop environment's defaults. This may be obscure and poorly documented. Also, setting loose permissions in this way can have security drawbacks, especially if yours is a multi-user system.
A better approach is to synchronize your account UIDs across Linux and OS X. You can easily change the UID value in Linux with the
usermod command, as in:
usermod -u 501 dale
This command sets the UID for
dale to 501. There are some significant caveats, though:
- You should log out of the account you're modifying before you modify it. Trying to modify an in-use account will cause that account to begin behaving strangely.
usermod must be used as
root. You can execute it via
sudo, but doing so from the account you're modifying is inadvisable in the extreme. Thus, you'll need to either give
root a password and log into
root directly or use
sudo from a second user account.
usermod command won't change the ownership of any files owned by the user in question. To adjust ownership of those files, you'll need to locate them and then change their ownership with
chown. Most of the files will be in the user's home directory, so
chown -R dale: /home/dale, typed as
root after changing
dale's UID, will change most of
dale's files to use the new UID number. Some of the user's files may be located elsewhere, though. Typing
find / -uid 1000 will find all the files that use the old UID (assuming it was 1000). Note that this
find command will probably take several minutes to complete. To speed it up, unmount any filesystems on which you're sure it will find no hits, such as FAT or NTFS volumes.
- If you access FAT or NTFS volumes, their UID values are determined by options at mount time. If you use a GUI file manager, chances are the UID value is set to whoever is running the file manager, so you need do nothing special. If you mount the volume via an
/etc/fstab entry, though, you may need to adjust the UID value it specifies.
- Ubuntu stores the minimum value it uses for UIDs in
/etc/login.defs. If you fail to change the
UID_MIN value in this file, you'll likely discover that your account will seem to "disappear" from the GUI login screen, and perhaps from some other systems. Thus, you should edit that file.
In theory, you could change the UID of your OS X account(s) in a similar way to achieve the same goal. I'm less familiar with the OS X account-maintenance tools, though, so I can't provide explicit instructions for doing so. Adjusting the OS X values would have the advantage of your not having to adjust
UID_MIN in Linux.
If you've got multiple accounts on your computer, you should adjust them all to keep them all synchronized across your OS installations.
One more point: The Group ID (GID) value is stored in a similar way. IIRC, Ubuntu assigns a GID value for each account that's identical to its UID value. I don't recall what OS X does by default. You might want to adjust the GID values for the two OSes in a way that's analogous to the UID changes, but this isn't likely to be as important as adjusting the UID values.
EDIT: If you want to change your UID (and GID, if desired) in macOS/OS X rather than in Ubuntu, you can do so. As this modification in macOS is beyond the scope of this site, I'll just link to a few pages that provide procedures for doing this in macOS: