4 Replies Latest reply: Jan 4, 2013 5:55 PM by guantero
guantero Level 1 Level 1 (0 points)

I have 9 User ID's that I want to make consistent accross two macs:

iMac

MBPro

 

Background:

This should be no problem for the iMac because I made a clean install on a new hard drive (with Mountain Lion).  Some will be new users.  Some will be migrated from the previous setup on a previous hard drive (with Leopard).  It should work if I do it in the order I want.  (I saw advice from Pondini in the pink & green boxes in Problems after using Migration Assistant).

 

On both Macs I use UID=501 as an admin account.

 

The MBPro already had three User's set up.  Only one was a User with data that needed to be preserved, but I wanted to change its UID to match my scheme for both Macs.  (I know there is the User ID field in the "Advanced Options" of the Users & Groups preferences; but I did not want to manually change that.)  I made a clone of the MBPro drive and thought I could delete all but the 501 admin account and then use Migration Assistant to bring that User account back to the MBPro in the sequence I wanted for the UID's in a similar manner as I hope to do for the iMac.

 

On the MBPro, I also noticed that several group IDs appeared in the Users & Groups preferences that included Group ID's including ones with numbers 506 and 508 that I wanted to use for the Users.  It may have acquired those GID's from connecting and sharing with the Users and Groups on the previous iMac setup.  Since those GID's were not needed yet on the MBPro (and I think no files on the MBPro have permissions set with those groups), I thought if I deleted them then it would free up those ID's to be used for my User ID setup sequence.  The MBPro currently has Lion.  I thought I would get the Users set up in my desired sequence, then update it to Mountain Lion.

 

The above is background for the problem below.

 

PROBLEM:

I successfully added users up to UID=505 on the MBPro.  Then when I attempted to add the next user, it assigned UID=507 (skipping 506).

 

QUESTION:

Where do I look and how can I eliminate any lingering references to UID or GID=506, so that I can successfully add a new user with UID=506?

I prefer to avoid changing things manually or with terminal.  I want the system to do it.

 

Thanks.


Mac OS X (10.7.5)
  • 1. Re: Trying to get the next assigned UID.
    Topher Kessler Level 6 Level 6 (9,340 points)

    I dont recommend you go about modifying user IDs as this can break their access to resources they own or otherwise ought to be able to access; however, if you need to then the tool to do this with is the command-line utility "dscl" for modifying the account directory. You can use this tool to both add and modify user account information on the system, including the ID of a user. For example, the following will output the current user's ID (optionally substitute `id -un` for the username of choice):

     

    dscl . -read /Users/`id -un` UniqueID

     

    To edit this, you the following should work:

     

    dscl . -change /Users/`id -un` UniqueID `id -u` NEWVALUE

     

    This will change the current user ID to that provided by NewValue. Again this will only do so in the directory similar to doing so in the Advanced preferences.

     

    To create a new user with dscl, you will need to provide a number of attributes such as the following:

     

    dscl . -create /Users/newperson

    dscl . -create /Users/newperson RealName "Full Name"

    dscl . -create /Users/newperson PrimaryGroupID NUMBER

    dscl . -create /Users/newperson Password PASSWORD

    dscl . -create /Users/newperson GroupMembership admins

    dscl . -create /Users/newperson UniqueID NUMBER

     

    These are only some of the attributes you'll need. The rest include the home directory and the default shell. While you can create a home directory for the user from scratch, Apple offers a default user template at /System/Library/User Template/ which you can copy and then adjust permissions accordingly.

  • 2. Re: Trying to get the next assigned UID.
    guantero Level 1 Level 1 (0 points)

    You're right, I don't want to manually modify any user IDs, all I want is for the system to assign the next UID in sequence, but it seemed to skip one (see the bottom of my post).  I don't want to accomplish my goal with terminal commands.  I just want the system to do what I think it should do.

     

    Interestingly, after my original post, I was able to get the system to assign the next UID=506 to a new user, but after trying and failing several times with one name, I was finally able to get it to work with another name.  Maybe it had nothing to do with using a different name, maybe it had more to do with closing system prefs or logging out of the admin account and logging back in.  (I was using the normal "+" add user feature in system preferences for users & groups.  However, I keep having similar trouble.  If I delete a temporary user, and then try to add a user, why won't the system add the next lowest available UID number?

     

    Also, forgot to mention in my original post.  Only my admin UID=501 is set up as admin.  All the other users are standard.

  • 3. Re: Trying to get the next assigned UID.
    guantero Level 1 Level 1 (0 points)

    On my MBPro with UID=501 as an admin acount and UID=502 as a real user account (standard) and UID=503 as a real user account "UserA" (standard), I deleted "UserA" and wanted to add new "UserB" as UID=503, but it gave me UID=512 for "UserB" instead.  So I deleted "UserB" and temporarily added ten more standard users and one more temparary admin user with the following names and successfully obtained a continuous sequence of UID's as follows:

     

    UID   Name

    503   UserA (temporarily added new account with same name as previous account)

    504   temp04

    505   temp05

    506   xtempA

    507   xtempB

    508   xtempC

    509   xtempD

    510   xtempE

    511   xtempF

    512   xtempG

    513   xtempH (admin)

     

    After adding "temp05" and getting UID=505, I attemped to add "temp06" but it gave me "509" instead of "506".  I deleted "temp06" and added "xtempA" and got UID=506.  Why does 506 it work for "xtempA" but not for "temp06"?  I don't think I ever used these names before.

     

    Next, in an attempt to get new "UserB" into UID=503, I deleted "UserA" again, and added new "UserB" again (this time with UID=512 already assigned to "xtempG"), but instead of getting 503 for "UserB" as I hoped for, I got UID=514.  Why does 503 work when I add a new user with the same name as the previously deleted "UserA", but it does not work for "UserB"?

     

    Next, I think I will try to add new "UserB" to my clone drive, then Migrate it, and see if that gets it into 503.

  • 4. Re: Trying to get the next assigned UID.
    guantero Level 1 Level 1 (0 points)

    It worked!

     

    I added a new "UserB" to my clone drive, then using Migration Assistant, brought it back into the MBPro.  With Migration Assistand it was assigned UID=503.

     

    So apparently Migration Assistant reliably assigns the next available UID (whether or not that UID was used by a previous but now deleted user account); whereas adding a new user through system preferences was not predictable.