OpenBSD manual page server

Manual Page Search Parameters

ADDUSER(8) System Manager's Manual ADDUSER(8)

adduser, rmuseradd and delete users from the system

adduser [-batch username [group[,group...] [fullname] [password]] [-check_only] [-class login_class] [-config_create] [-dotdir directory] [-e method-encryption method] [-group login_group] [-h | -help | -?] [-home partition] [-message file] [-noconfig] [-shell shell] [-s | -silent | -q | -quiet] [-uid_start uid] [-uid_end uid] [-v | -verbose] [-unencrypted]


rmuser [username]

The adduser program adds new users to the system. The rmuser program removes users from the system. When not passed any arguments, both utilities operate in interactive mode and prompt for any required information.

The options are as follows:

username [group[,group] ...] [fullname] [password]
Enter batch mode in which multiple users are specified on the command line in a compact format. By default the password is assumed to already be properly encrypted.
Check the passwd, group, and shells databases for consistency and problems then exit without performing any other operation.
login_class
Use the specified login_class as the default user login class. See login.conf(5) for further details.
Create or edit default configuration information and message file before proceeding with the normal interactive adduser procedure.
directory
Copy files from directory into the HOME directory of new users. Files named in the fashion of “dot.foo” will be renamed to “.foo”. By default, all files are made writable and readable by their owner.
, -e method
Encrypt local passwords using method of encryption as described in login.conf(5). If method is “auto”, the encryption type will be derived from the user's login class.
login_group
Specify the default login group. A value of USER means that the username is to be used as the login group.
, -h, -?
Print a summary of options and exit.
partition
Specify the default home partition where all users' home directories are to be located.
file
Send new users a welcome message from file. Specifying a value of “no” for file causes no message to be sent to new users.
Do not read the default configuration file.
shell
Specify the default shell for new users.
, -s, -quiet, -q
Causes the program to print fewer warnings, questions, and bug reports.
uid
Use UIDs from uid up when automatically generating UIDs.
uid
Do not use UIDs higher than uid when generating UIDs.
Causes the program to assume that the password given in batch mode is unencrypted. The password will be encrypted before being added to the password file. Use of this option is discouraged, as the username and cleartext password will appear in the process list, which is visible to users.
, -v
Causes the program to print many warnings and questions. This option is recommended for novice users.

adduser first performs consistency checks on the password, group, and shell databases. This includes finding any duplicate user or group names, illegal shells, or shells that aren't executable. Once these tests are passed, adduser performs the following operations for each new user:

  1. Add the appropriate entries to the password and group files and re-generate the password database using pwd_mkdb(8).
  2. Create a home directory and copy all files from the skeletal login directory (normally /etc/skel) to this new directory. Files named in the fashion of “dot.foo” will be renamed to “.foo” in the new directory.
  3. Mails the new user a welcome message at the discretion of the account creator.

Similarly, when removing a user, rmuser performs the following operations for the given username:

  1. Removes any crontab(1) entries or at(1) jobs belonging to the user.
  2. Removes the user from the password database and all groups in the group database. If a group becomes empty and its name is the same as the username, the group is removed (this complements adduser's unique per-user groups).
  3. Recursively deletes all files in the user's home directory and removes the directory itself (provided the directory actually belongs to the user). rmuser prompts for confirmation before actually doing this.
  4. Removes the user's incoming mail file if one exists.

Understandably, rmuser politely refuses to remove users whose UID is 0 (typically root).

It is recommended that login names contain only lowercase characters and digits. They may also contain uppercase characters, non-leading hyphens, periods, underscores, and a trailing ‘$’. Login names may not be longer than 31 characters. If you need a longer login name for email addresses, you can define an alias in /etc/mail/aliases.
This should contain the user's first name and surname. The ‘:’ is not permitted.
The specified user login class must exist in /etc/login.conf.
Only valid entries from the shells(5) database or entries corresponding to pppd(8) are permitted.
This value is the start of the range where free UID values are searched for. This value must be less than the value of uid_end. The default value is 1000 or as configured in the configuration file.
This value is the end of the range where free UID values are searched for. This value must be more than the value of uid_start. The default value is 2147483647 or as configured in the configuration file.
This value is generated automatically, but can be specified at the discretion of the person invoking the program.
If not empty, the password is encrypted according to login.conf(5). If empty, the account will be automatically disabled to prevent spurious access to it.

adduser follows these steps to extract its configuration information:

  1. Read internal variables.
  2. Read configuration file (/etc/adduser.conf).
  3. Parse command-line options.

The format is explained within that file and is quite straightforward. The configuration file will be created the first time adduser is run.

/etc/master.passwd
user database
/etc/group
group database
/etc/shells
shell database
/etc/ptmp
lock file for the passwd database
/etc/adduser.conf
configuration file for adduser
/etc/adduser.message
message file for adduser
/etc/skel
skeletal login directory
/var/log/adduser
log file for adduser

Start adduser in interactive mode:

# adduser

Create user “falken” and login group “falken”. Invite user “falken” into groups “guest”, “staff”, and “beer”. Realname (fullname) is “Prof. Falken”. The password has been created using encrypt(1):

# adduser -batch falken guest,staff,beer 'Prof. Falken' \
    '$2b$10$aOadQNznQ1YJFnqNaRRneOvYvZAEO7atYiTND3EsLf6afHT5t1UIK'

Create user “vehlefanz” in login group “guest”. Start the free UID search at 5000. No other groups, no realname, no password. Send a welcome message:

# adduser -uid_start 5000 -group guest \
    -message /etc/adduser.message -batch vehlefanz

Create user “jsmith” and place in the “jsmith” login group. Also add to the “staff” group. No password:

# adduser -group USER -batch jsmith staff

chpass(1), finger(1), passwd(1), setlogin(2), aliases(5), group(5), login.conf(5), passwd(5), shells(5), nologin(8), pwd_mkdb(8), vipw(8), yp(8)

June 9, 2017 OpenBSD-7.0