Veja /etc/adduser.conf
:
# FIRST_SYSTEM_[GU]ID to LAST_SYSTEM_[GU]ID inclusive is the range for UIDs
# for dynamically allocated administrative and system accounts/groups.
# Please note that system software, such as the users allocated by the base-passwd
# package, may assume that UIDs less than 100 are unallocated.
FIRST_SYSTEM_UID=100
LAST_SYSTEM_UID=999
FIRST_SYSTEM_GID=100
LAST_SYSTEM_GID=999
# FIRST_[GU]ID to LAST_[GU]ID inclusive is the range of UIDs of dynamically
# allocated user accounts/groups.
FIRST_UID=1000
LAST_UID=29999
FIRST_GID=1000
LAST_GID=29999
E, lendo o script Perl em $(type -p adduser)
ou /usr/sbin/adduser
, encontramos essa função:
sub first_avail_uid {
my ($min, $max) = @_;
printf (gtx("Selecting UID from range %d to %d ...\n"),$min,$max) if ($verbose > 1);
my $t = $min;
while ($t <= $max) {
return $t if (!defined(getpwuid($t)));
$t++;
}
return -1; # nothing available
}
O que isto significa é: adduser
escolhe o primeiro UID livre entre 1000 e 29999 ou falha.
Resposta exata: 1002, escolherá uma grátis.
Existe um UID máximo, 4294967295
, porque UID
s são campos de 32 bits, mas adduser
usa um limite inferior.
No entanto, também há /usr/sbin/useradd
BEWARE adduser
e useradd
são facilmente confundidos / equivocados entre si.
man useradd
me diz:
DESCRIPTION
useradd is a low level utility for adding users. On Debian,
administrators should usually use adduser(8) instead.
...
-u, --uid UID
The numerical value of the user's ID. This value must be unique,
unless the -o option is used. The value must be non-negative. The
default is to use the smallest ID value greater than or equal to
UID_MIN and greater than every other user.
See also the -r option and the UID_MAX description.
...
CONFIGURATION
The following configuration variables in /etc/login.defs change the
behavior of this tool:
...
SYS_UID_MAX (number), SYS_UID_MIN (number)
Range of user IDs used for the creation of system users by useradd
or newusers.
The default value for SYS_UID_MIN (resp. SYS_UID_MAX) is 101
(resp. UID_MIN-1).
UID_MAX (number), UID_MIN (number)
Range of user IDs used for the creation of regular users by useradd
or newusers.
The default value for UID_MIN (resp. UID_MAX) is 1000 (resp.
60000).
Um motivo pelo qual eu uso adduser
, em vez de useradd
, é a opção --encrypt-home
para adduser
. Qualquer um, no entanto, poderia ser substituído editando um monte de arquivos, copiando outros, criando diretórios, etc usando qualquer um UID picks (Por que, nos velhos tempos, eu ...). Não há nada de mágico sobre adduser
ou useradd
.