Useradd

無法再使用 useradd 添加使用者

  • November 1, 2015

每當我這樣做

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

useradd 只是拒絕添加任何使用者並列印:

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

只是告訴你,它/etc/passwd有 9056 行長。

可能是什麼問題呢?

根據 man useradd,它會創建為每個使用者保留的 SUB_UID_COUNT 輔助 uid 範圍

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.

看起來達到了預設限制並且 useradd 失敗了

引用自:https://unix.stackexchange.com/questions/240119