uid greater than...

Mike Reinehr cmr
Sat Dec 30 12:02:31 PST 2006


Jorge,

On Saturday 30 December 2006 13:40, Jorge Almeida wrote:
> On Sat, 30 Dec 2006, Mike Reinehr wrote:
> > On Saturday 30 December 2006 07:36, Jorge Almeida wrote:
> >> When creating a new user, is there some way to force the uid to be
> >> greater than some value? I know I can do "useradd -u 10030 ...", for
> >> example, but that's not what I mean. The man page for useradd says that
> >> by default (i.e., without using the -u flag) the new user uid will be
> >> the smallest value greater than 999 and greater than every other
> >> existing user's uid. I want this behaviour with 10000 instead of 999
> >> (for some users, not for all of them).
> >> Is there some way do do it at all (short of cooking a wrapper that would
> >> check the uid of existing users)?
> >
> > Check out the `adduser` command (rather than the `useradd` command). It
> > has a configuration file (/etc/adduser.conf) which, among other options
> > includes:
> >
> > # FIRST_UID to LAST_UID inclusive is the range of UIDs of dynamically
> > # allocated user accounts.
> > FIRST_UID=1000
> > LAST_UID=29999
> >
> > You also have the option of using multiple configuration files.
>
> Seems promising, but in my gentoo system /usr/sbin/adduser is just a
> symlink to /usr/sbin/useradd! It belongs to the package shadow-4.0.18.1.
> No separate man page, of course.
> Can you check whether it is the same package in your system?
> And what is your distro? I'll ask the gentoo list with those data.
>
> Thanks.

I'm using Debian 'Etch'. On this system adduser is a perl script:

cmr at odin:/usr/sbin$ ls -l adduser
-rwxr-xr-x 1 root root 32106 Nov 26 15:13 adduser
cmr at odin:/usr/sbin$ file adduser
adduser: perl script text executable

Here's the man page:

ADDUSER
 Section: Maintenance Commands (8) 
NAME
 adduser, addgroup - add a user or group to the system 
SYNOPSIS
adduser [options] [--home DIR] [--shell|-s SHELL] [--no-create-home] [--uid 
ID] [--firstuid ID] [--lastuid ID] [--ingroup GROUP | --gid ID] 
[--disabled-password] [--disabled-login] [--gecos GECOS] [--add_extra_groups] 
user 

 adduser --system [options] [--home DIR] [--shell SHELL] [--no-create-home] 
[--uid ID] [--group | --ingroup GROUP | --gid ID] [--disabled-password] 
[--disabled-login] [--gecos GECOS] user 

 adduser --group [options] [--gid ID] group 
 addgroup [options] [--gid ID] group 

 adduser --group --system [options] [--gid ID] group 
 addgroup --system [options] [--gid ID] group 

 adduser [options] user group 
COMMON OPTIONS

 [--quiet] [--debug] [--force-badname] [--help|-h] [--version] [--conf FILE] 
DESCRIPTION


 adduser and addgroup add users and groups to the system according to command 
line options and configuration information in /etc/adduser.conf. They are 
friendlier front ends to the low level tools like useradd, groupadd and 
usermod programs, choosing Debian policy conformant UID and GID values, 
creating a home directory with skeletal configuration, running a custom 
script, and other features. adduser and addgroup can be run in one of five 
modes: 
Add a normal user
 If called with one non-option argument and without the --system or --group 
options, adduser will add a normal user. 
adduser will choose the first available UID from the range specified for 
normal users in the configuration file. The UID can be overridden with 
the --uid option. 
 The range specified in the configuration file may be overridden with 
the --firstuid and --lastuid options. 
 By default, each user in Debian GNU/Linux is given a corresponding group with 
the same name. Usergroups allow group writable directories to be easily 
maintained by placing the appropriate users in the new group, setting the 
set-group-ID bit in the directory, and ensuring that all users use a umask of 
002. If this option is turned off by setting USERGROUPS to no, all users' 
GIDs are set to USERS_GID. Users' groups can also be overridden from the 
command line with the --gid or --ingroup options to set the group by id or 
name, respectively. Also, users can be added to one or more groups defined in 
adduser.conf either by setting ADD_EXTRA_GROUPS to 1 in adduser.conf, or by 
passing --add_extra_groups on the commandline. 
adduser will create a home directory subject to DHOME, GROUPHOMES, and 
LETTERHOMES. The home directory can be overridden from the command line with 
the --home option, and the shell with the --shell option. The home 
directory's set-group-ID bit is set if USERGROUPS is yes so that any files 
created in the user's home directory will have the correct group. 
adduser will copy files from SKEL into the home directory and prompt for 
finger (gecos) information and a password. The gecos may also be set with 
the --gecos option. With the --disabled-login option, the account will be 
created but will be disabled until a password is set. The --disabled-password 
option will not set a password, but login is still possible (for example with 
SSH RSA keys). 
 If the file /usr/local/sbin/adduser.local exists, it will be executed after 
the user account has been set up in order to do any local setup. The 
arguments passed to adduser.local are: 
 username uid gid home-directory 
 The environment variable VERBOSE is set according to the following rule: 

0 if --quiet is specified
1 if neither --quiet nor --debug is specified
2 if --debug is specified
 (The same applies to the variable DEBUG, but DEBUG is deprecated and will be 
removed in a later version of adduser.) 
Add a system user
 If called with one non-option argument and the --system option, adduser will 
add a system user. If a user with the same name already exists in the system 
uid range (or, if the uid is specified, if a user with that uid already 
exists), adduser will exit with a warning. 
adduser will choose the first available UID from the range specified for 
system users in the configuration file. The UID can be overridden with 
the --uid option. 
 By default, system users are placed in the nogroup group. To place the new 
system user in an already existing group, use the --gid or --ingroup options. 
To place the new system user in a new group with the same ID, use the --group 
option. 
 A home directory is created by the same rules as for normal users. The new 
system user will have the shell /bin/false (unless overridden with 
the --shell option), and have logins disabled. Skeletal configuration files 
are not copied. 
Add a user group
 If adduser is called with the --group option and without the --system option, 
or addgroup is called respectively, a user group will be added. 
 A GID will be chosen from the range specified for user UIDS in the 
configuration file. The GID can be overridden with the --gid option. 
 The group is created with no users. 
Add a system group
 If addgroup is called with the --system option, a system group will be added. 
 A GID will be chosen from the range specified for system GIDS in the 
configuration file. The GID can be overridden with the --gid option. 
 The group is created with no users. 
Add an existing user to an existing group
 If called with two non-option arguments, adduser will add an existing user to 
an existing group. 
OPTIONS


--conf FILE 
 Use FILE instead of /etc/adduser.conf. 
--disabled-login 
 Do not run passwd to set the password. The user won't be able to use her 
account until the password is set. 
--disabled-password 
 Like --disabled-login, but logins are still possible (for example using SSH 
RSA keys) but not using password authentication. 
--force-badname 
 By default, user and group names are checked against a configurable regular 
expression. This option forces adduser and addgroup to apply only a weak 
check for validity of the name. 
--gecos GECOS 
 Set the gecos field for the new entry generated. adduser will not ask for 
finger information if this option is given. 
--gid ID 
 When creating a group, this option forces the new groupid to be the given 
number. When creating a user, this option will put the user in that group. 
--group 
 When combined with --system, a group with the same name and ID as the system 
user is created. If not combined with --system, a group with the given name 
is created. This is the default action if the program is invoked as addgroup. 
--help 
 Display brief instructions. 
--home DIR 
 Use DIR as the user's home directory, rather than the default specified by 
the configuration file. If the directory does not exist, it is created and 
skeleton files are copied. 
--shell SHELL 
 Use SHELL as the user's login shell, rather than the default specified by the 
configuration file. 
--ingroup GROUP 
 Add the new user to GROUP instead of a usergroup or the default group defined 
by USERS_GID in the adduser.conf file. 
--no-create-home 
 Do not create the home directory, even if it doesn't exist. 
--quiet 
 Suppress informational messages, only show warnings and errors. 
--debug 
 Be verbose, most useful if you want to nail down a problem with adduser. 
--system 
 Create a system user. 
--uid ID 
 Force the new userid to be the given number. adduser will fail if the userid 
is already taken. 
--firstuid ID 
 Override the first uid in the range that the uid is chosen from. 
--lastuid ID 
 Override the last uid in the range that the uid is chosen from. 
--add_extra_groups 
 Add new user to extra groups defined in adduser.conf 
--version 
 Display version and copyright information. 
FILES
 /etc/adduser.conf 
SEE ALSO
adduser.conf(5), deluser(8), useradd(8), groupadd(8), usermod(8), Debian 
Policy 9.2.2. 
COPYRIGHT
 Copyright (C) 1997, 1998, 1999 Guy Maor. Modifications by Roland Bauerschmidt 
and Marc Haber. 
 Copyright (C) 1995 Ted Hajek, with a great deal borrowed from the original 
Debian adduser 
 Copyright (C) 1994 Ian Murdock. adduser is free software; see the GNU General 
Public Licence version 2 or later for copying conditions. There is no 
warranty.

cmr
-- 
Debian 'Etch': Registered Linux User #241964

"More laws, less justice." -- Marcus Tullius Ciceroca, 42 BC



More information about the Linux-users mailing list