To add a user:
-
Log in as root.
- Use passwd:
passwd new_username
Note:
Make sure that the user name is no longer than 255 characters; otherwise, that
user won't be able to log in.
If you specify a user name that's already registered,
passwd assumes you want to change their password. If that's what
you want, just type in the new password and then confirm it. If you don't wish to change
the user's password, press CtrlC to terminate the
passwd utility without changing anything.
If the user name isn't already registered, passwd
prompts you for account information, such as the user's group list, home directory, and
login shell. The /etc/default/passwd configuration file specifies
the rules that determine the defaults for new accounts. For more information, see the
description of this file in the documentation for
passwd.
The prompts include:
- User id # (default)
- Specify the numeric user ID for the new user. By default, no two users may share
a common user ID, because applications won't be able to determine the user name
that corresponds to that user ID.
- Group id # (default)
- Choose a numeric group ID that the user will belong to after initially logging in.
Note:
The
passwd utility doesn't add the new user to the
group's entry in the
/etc/group file; you need to do
that manually using a text editor. See
Defining Groups
for more details.
- Real name ()
- Enter the user's real name. The real name isn't widely used by system utilities,
but may be used by applications such as email.
- Home directory (/home/username)
- Enter the pathname of the user's home directory, usually
/home/username.
The passwd utility automatically
creates the directory you specify. If the directory already exists,
passwd by default prompts you to select a different
pathname. For information on disabling this feature, see the description of
/etc/default/passwd in the documentation for
passwd.
- Login shell (/bin/sh)
- This is the program that's run once the user logs in. Traditionally, this is the
shell (/bin/sh), giving the user an interactive command line
upon logging in.
Note:
You can specify any program as the login shell, but you can't pass
command-line arguments to it.
Instead of specifying a custom program within the account entry, you should
customize the user's .profile file in their home
directory; /bin/sh runs this profile automatically when
it starts up. For more information, see
Configuring Your Environment.
- New password:
- Specify the initial password for the account. You're asked to confirm it by typing it again.