How to change userID

Discussion in 'Mac OS X Lion (10.7)' started by sirozzy, Feb 8, 2012.

  1. sirozzy, Feb 8, 2012
    Last edited: Feb 9, 2012

    sirozzy macrumors member

    sirozzy

    Joined:
    Jun 27, 2010
    Location:
    @home
    #1
    Hi there.

    I need to change userid from 501 to 1066 to mach my NFS share folder on remote server. I did found a solution for Snow Leopard but im running Lion so I'm not sure if it's the same and dont want to mess up my mac.

    Thanks a lot
     
  2. sirozzy thread starter macrumors member

    sirozzy

    Joined:
    Jun 27, 2010
    Location:
    @home
    #2
    Sollution for Snow Leo and Lion

    UserID Fixing

    UserID in MacOS and NFS Share has to mach!

    First of all, don't do this while you are logged in as the user whose uid you want to change.
    *
    Prerequisites
    One clean way of doing this is as the root user. To do that, you have to*enable the root user on your Mac OS X. Log in as root as described in Apple's article.
    *

    Do not use sudo being loged in as normal user even if you have admin privileges.*
    *
    Change UID
    Read the uid (given Alice as the user's name, 501 as old and 1234 as the new uid):
    Code:
    # dscl . -read /Users/Alice UniqueID
    UniqueID: 501 
    
    # dscl . -change /Users/Alice UniqueID 501 1234
    
    # dscl . -read /Users/Alice UniqueID
    UniqueID: 1234
    *
    Change ownership of the user's files
    Code:
    # find /Users/Alice -user 501 -exec chown 1234 {} \;
    # find /Library -user 501 -exec chown 1234 {} \;
    # find /Applications -user 501 -exec chown 1234 {} \;
    # find /usr -user 501 -exec chown 1234 {} \;
    # find /private/var/ -user 501 exec chown 1234 {} \; 
    or use this one if you sure no remote filesystem is mounted

    Code:
    # find -xL / -user 501 -exec chown 1234 {} \;
    A simple test if there are files left that are owned by the old uid:
    # find -xL / -user 501 -ls
    Rename special files and folders
    But that was not all. Mac OS X has some special files and folders that have the (old) uid as part of their names. These include (on my Mac, ymmv):

    /.Trashes/501
    /Library/Caches/com.apple.ImageCaptureExtension2.ICADeviceDatabase.501
    /Library/Caches/com.apple.ImageCaptureNotifications.DeviceDiscoveryDatabase.501
    /private/var/db/launchd.db/com.apple.launchd.peruser.501
    and possibly some files in /private/var/folders/ud/(some ugly dir name)/-Caches-/
    For every of the above you have to do something like:
    # mv /.Trashes/501 /.Trashes/1234
     

Share This Page