I. INTRODUCTION
Linux is a multiuser system, so it has many user accounts. Even if you are the only user on your system, many servers require a unique
user- name and group name.
Also, users can belong to one or more groups. Typically, each username has a corresponding private group name. By default, each user
belongs to that corresponding private group. However, you can define other groups for the purpose of providing access to specific files
and directories based on group membership.
User and group ownerships of files are a way to make sure that only the right people (or the right process) can access the right files and
directories. Managing the user and group accounts is a typical system administration job. Its not that hard to do this part of the job,
given the tools that come with Linux. I show you how in this chapter.
On the other hand, much of Linux system administration deals with handling mundane day-to-day tasks. Many of these tasks relate to
users and groups: adding them, deleting them, configuring the environments, and so on.
On a small system, you might perform such tasks infrequently, but on a busy system, you might adjust accounts frequently. In any event,
you must know how to do these things.
Managing Users and Groups 2
II. PROCEDURES
2. User might wish to change their passwords at a future date. Here is how unprivileged user would change his own
password. Login as usertest02 user and use passwd command to change the password.
1. To delete a user and its home directory, use the command deluser.
To find out more about the adduser, deluser, and usermod commands, type man adduser, man deluser, or man usermod
in a terminal window.
Managing Users and Groups 4
1. The /etc/passwd file is a list of all user accounts. Its a text file and any user can read it no special privileges needed. Each
line in /etc/passwd has seven fields, separated by colons (:).
username usertest03
password x
user id 1003
group id 1003
user information (optional) User Test 03
home directory /home/user/usertest03
login shell /bin/bash
Managing Users and Groups 5
Parameter Description
Username An alphanumeric username, usually eight characters long and unique (Linux allows usernames to
be longer than eight characters, but some other operating system do not)
Password When present, a 13-charater encrypted password(an empty field means that no password is
required to access the account, an x means the password is stored in the /etc/shadow file, which
is more secure)
UID A unique number that serves as the user identifier (root has UUID of ) and usually the UIDs
between 1 to 100 are reserved for non-human users such as servers; keeping the UID less than
32762 is best)
GID The default group ID of the group to which the user belongs (GID 0 is for group root, other groups
are defined in /etc/group and users can be and usually are in more than one group at a time)
GECOS Optional personal information about the user (the finger command uses this field and GECOS
stands for General Electric Comprehensive Operating System, a long-forgotten operating system
thats immortalized by the name of this in /etc/passwd)
homedir The name of the users home directory
shell The command interpreter (shell), such as Bash(/bin/bash), that executes when this user logs in
Managing Users and Groups 6
Managing Groups
1. A group is something to which users belong. A group has a name and an identification number (ID). After a group is
defined, users can belong to one or more of these groups. You can find all the existing groups listed in /etc/group.
groupname sudo
password X
group id 27
membership testadmin
Parameter Description
groupname The name of the group (for example, wheel)
Password The group password (an x means that password is stored in the /etch/shadow file)
GID The numerical group ID (for example, 10)
membership A comma-separated list of usernames that below to this group (for example, root, naba)
grouptest01
grouptest02
grouptest03
3. To remove a group, use the delgroup command. For example, to remove group named grouptest03, type delgroup
grouptest03.
4. To add a user usertest01 in a group namely grouptest01 and grouptest02 , use the below command
5. To add multiple users in a group use gpasswd command. For instance, to add usertest01 and usertest02 to grouptest01
use the below command:
1. In Linux, each file or directory has two types of owners a user and a group. In other words, a user and group own each
file and directory. The user and group ownerships can control who can access a file or directory.
2. To view the owner of a file or directory, use the ls -l command to see the detailed listing of a directory. For example, heres
a typical files information:
3. In this example, the first set of characters shows the files permission setting who can read, write, or execute the file.
The third and fourth fields (in this example, testadmin testadmin) indicate the user and group owner of the file. Each user
has a private group that has the same name as the username. So most files user and group ownership appear to show
the username twice. As a system administrator, you may decide to change the group ownership of a file to a common
group.
4. Change the group ownership and user owner of testfile01.txt file to the grouptest01 and usertest01 respectively. To do
that, log in as root and type the following commands:
5. In fact, chown can change both the user and group owner at the same time. For example, to change testfile01.txt user
owner to user.test02 and the group owner to grouptest02, type below command:
Managing Users and Groups 9
2. Directory modes
Mode Description
rwx full access
r-w limited access (enter and read)
--- no access
3. Change testfile01.txt permission : user full access, group limited access and others no access.