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 '15 at 16:53
  • No. They are 1000 and 60000 respectively as it came with my distro. – tildearrow Nov 1 '15 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 '15 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 '15 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 '15 at 17:05

As per man useradd, 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

Looks like that default limit reached and useradd is failing

| improve this answer | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.