Whenever I do

# useradd -N --gid 1003 -s /bin/ksh --uid <some UID starting with 10027> --home /home/<someuser> <someuser>

useradd just refuses to add any user and prints instead:

useradd: Can't get unique secondary UID range
useradd: can't find subordinate user range

And just to tell you, the /etc/passwd is 9056 lines long.

What could be the problem?

  • Do you have any custom limits on UID range? defined in /etc/login.defs UID_MIN,UID_MAX ?
    – VenkatC
    Nov 1, 2015 at 16:53
  • No. They are 1000 and 60000 respectively as it came with my distro.
    – tildearrow
    Nov 1, 2015 at 16:56
  • What OS are you running? are you in a container environment? check for subuid/gid definitions or files /etc/subuid, /etc/subgid
    – VenkatC
    Nov 1, 2015 at 17:01
  • Ubuntu 14.04. uname: Linux server 3.19.0-28-lowlatency #30~14.04.1-Ubuntu SMP PREEMPT Tue Sep 1 10:24:39 UTC 2015 x86_64 x86_64 x86_64 GNU/Linux
    – tildearrow
    Nov 1, 2015 at 17:04
  • And no I am not. And how do I check that? I opened /etc/subuid and the highest value was 600016544.
    – tildearrow
    Nov 1, 2015 at 17:05

2 Answers 2


As per useradd(8), it creates SUB_UID_COUNT secondary uid range reserved for each user

SUB_UID_MIN (number), SUB_UID_MAX (number), SUB_UID_COUNT (number)

    If /etc/subuid exists, the commands useradd and newusers (unless the user already have subordinate user IDs) allocate SUB_UID_COUNT unused user IDs from the range SUB_UID_MIN to SUB_UID_MAX for each new user.

    The default values for SUB_UID_MIN, SUB_UID_MAX, SUB_UID_COUNT are respectively 100000, 600100000 and 10000.

Looks like you reached that default limit and therefore useradd is failing.


useradd is complaining that it cannot allocate a subordinate UID range for the new user because the allowed UID range is exhausted.  As you indicated, you have a lot of users in your system, and the default values configured in login.defs can't handle that.

Subordinate UID/GID files are used to set up UID/GID mappings for user namespaces (see subuid(5), subgid(5), newuidmap(1), and newgidmap(1) ).

In my case, I had 10000+ UIDs in my system, and  useradd was failing with exactly the same error.  I didn't want useradd to manage the subuid and subgid databases as I don't need to configure any custom ID mappings, so I've disabled this feature.  This can be done by removing the /etc/subuid and /etc/subgid files.

For recent versions of shadow utilities (since 4.9 or so), setting SUB_UID_COUNT 0 and SUB_GID_COUNT 0 in your /etc/login.defs also works.  See login.defs(5) for details.

You must log in to answer this question.

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