ADDUSER(8) — MAINTENANCE COMMANDS
NAME
adduser − procedure for adding new users
DESCRIPTION
To add a new user-account, the System Administrator (super-user):
1.Creates an entry for the new user in the system password file.
2.Creates a ‘home directory’ for the user, and changes its owner to the new user.
3.Perhaps sets up some skeletal profile files for the new user (.cshrc, .login, .profile...).
4.If the account is on a system running the Yellow Pages name service, there are additional steps.
Making an Entry in the Password File
The new user chooses a login name, which must not already appear in the password file, /etc/passwd, or the Yellow Pages password map.
To add an entry for the new login name on a local host, edit this file — inserting a line for the new user. This must be done with the password file locked, for instance, by using vipw(8), and the insertion must be made above the line containing the string:
+::0:0:::
This line is used to indicate that additional accounts can be found in the Yellow Pages.
To add an entry for the new login name on to the Yellow Pages, add an identical line to the file /etc/yp/src/passwd on the YP master server, and run make(1) in the directory /etc/yp (see ypmake(8) for details) to propagate the change.
The new user is assigned a group and user ID number. User ID numbers (or "userids", or "uids") should be unique for each user and consistent across the NFS domain, since they control access to files. Group ID numbers (or "groupids", or "gids") need not be unique. Typically, users working on similar projects will assigned to the same group. The system staff is group ‘10’ for historical reasons, and the super-user is in this group.
An entry for a new user ‘francine’ would look like:
francine::235:20:& Featherstonehaugh:/usr/francine:/bin/csh
Fields in each password-file entry are delimited by colons, and have the following meanings:
1.Login name (‘francine’). The login name is limited to eight characters in length.
2.Encrypted password. Typically, this field is left empty, so no password is needed when the user first logs in. If security demands a password, it should be assigned by running passwd(1) immediately after exiting the editor.
3.User ID. The user ID is a number which identifies that user uniquely in the system. Files owned by the user have this number stored in their data blocks, and commands such as ls(1V) use it to look up the owner’s login name. For this reason, you cannot just go merrily changing this number at random. (See passwd(5) for more information.)
4.Group ID. The group ID number identifies the group to which the user belongs by default (although the user may belong to addtional groups as well). All files that the user creates have this number stored in their data blocks, and commands such as ls(1V) use it to look up the group name. Group names and assignments are listed in the file /etc/group (which is described in group(5)) or in the Yellow Pages group map.
5.This field is called the ‘GCOS’ field (from earlier implementation of the UNIX system) and is traditionally used to hold the user’s full name. Some installations have other information encoded in this field. From this information we can tell that Francine’s real name is ‘Francine Featherstonehaugh’. The & here is a shorthand for the user’s login name.
6.User’s home directory. This is the directory in which that user is ‘positioned’ when they log in.
7.Initial shell which this user will see on login. If this field is empty, sh(1) is used as the initial shell.
Making a Home Directory
As shown in the password file entry above, the name of Francine’s home directory is to be /usr/francine. This directory must be created using mkdir(1), and Francine must be given ownership of it using chown(8), in order for her profile files to be read and executed, and to have control over access to it by other users:
tutorial# mkdir /usr/francine
tutorial# /etc/chown francine /usr/francine
tutorial#
If running under NFS, the mkdir(1) and chown(8) commands must be performed on the NFS server.
Setting Up Skeletal Profile Files
New users often need assistance in setting up their profile files to initialize the terminal properly, configure their search path, and perform other desired functions at startup. Providing them with skeletal profile files saves time and interruptions for both the new user and the System Administrator.
Such files as:
.profile
if they use /bin/sh as the shell, or
.cshrc and .login
if they use /bin/csh as the shell,
can include commands that are performed automatically at each login, or whenever a shell is invoked, such as tset(1). The ownership of these files must be changed to belong to the new user, either by running su(1), before making copies, or by using chown(8).
FILES
/etc/passwd password file
/etc/group group file
SEE ALSO
passwd(1), mkdir(1), chown(8), chsh(1), passwd(5), vipw(8)
Sun Network Services Guide, in Networking on the Sun Workstation.
Sun Release 3.5 — Last change: 11 October 1984