Chapter 3. Managing Groups and Users

Table of Contents

3.1. Creating New Users
3.1.1. Create an account
3.1.2. Activate the account with a new password
3.2. Working with groups
3.2.1. Belonging to groups
3.2.2. Joining a group
3.2.3. Creating and deleting groups
3.2.4. Adding a user to a group
3.3. Configuration files
3.3.1. The /etc/passwd and /etc/shadow files
3.3.2. The /etc/group and gshadow files
3.3.3. /etc/login.defs and /etc/skel/
3.4. Command options
3.5. Modifying accounts and default settings
3.5.1. Locking an account
3.5.2. Changing the password expiry dates
3.5.3. Removing an account
3.6. Exercises and Summary
3.6.1. Questions
3.6.2. Files
3.6.3. Commands
3.6.4. Exercises

Prerequisites

Goals

3.1. Creating New Users

3.1.1. Create an account

The /usr/sbin/useradd command adds new users to the system and the symbolic link adduser points to it.[1]

Syntax:

useradd [options] login-name

Example: add a user with login name rufus

useradd rufus
[Note]Note

On some systems the -m flag may be needed to force the creation of home directories

Default values will be used when no options are specified. You can list these values with useradd -D.

Default options listed with useradd -D

GROUP=100
HOME=/home
INACTIVE=-1
EXPIRE=
SHELL=/bin/bash
SKEL=/etc/skel	

Notice that this information is also available in the file /etc/default/useradd

3.1.2. Activate the account with a new password

To allow a user to access his or her account the administrator must allocate a password to the user using the passwd tool.

Syntax:

passwd login-name

These steps create a new user. This has also defined the user's environment such as a home directory and a default shell. The user has also been assigned to a group, his primary group.



[1] On Debian, adduser is a separate command providing an interactive method of adding a user account along with its password