You are on page 1of 15

CMPD153 System Administration

Chapter 2:
User Management
Objectives
Examine /etc/group and /etc/passwd
Create, modify, and delete user accounts with
useradd, usermod, and userdel
Overview

System Allocate User Consists User ID (derives from


Administrator Account actual name of the user)

/etc/group
Where is every user
commonly
represented? /etc/passwd

Commands to view the content:


$ cat /etc/group
$ cat /etc/passwd
/etc/group
Group database is maintained in /etc/group
Contains GID; number and name
A group compromises one or more members
having a separate set of privileges
A user has one primary group, AND may have
one or more supplementary group
/etc/group

Field 1 Field 2 Field 3 Field 4

root::0:root
Field 1: name GID
Field 2: blank or x hardly used today
Field 3: numeric GID
Field 4: list of user for which this is their
supplementary group
/etc/group
root users supplementary group
root::0:root Line 1
staff::1: Line 2
bin::2:root,bin,daemon Line 3
sys::3:root,bin,sys,adm Line 4
lp::8:root,lp,adm Line 5

O Line 1: num. GID = 0, name GID = root, supplementary group for


root user
O Line 2: num. GID = 1, name GID = staff, no user has staff as
supplementary group. Primary group for root
O Line 3: [fill in the blank]
O Line 4: [fill in the blank]
O Line 5: [fill in the blank]
/etc/group
groupadd command: Adding a group
Example: create a new group dba with a GID
of 241
groupadd g 241 dba
/etc/passwd
Store all user information except password
encryption
/etc/shadow stores password encryption
/etc/passwd and /etc/shadow use by
login and passwd programs - authentication
/etc/passwd

Numeric Comment or Login


Username UID GCOS shell

sn010101:x:210:241:Surizal Nazeri:/home/sn010101:bin/ksh

Password field Numeric Home Directory


(not used) GID
/etc/passwd
sn010101:x:210:241:Surizal Nazeri:/home/sn010101:bin/ksh

Username: name used to log on


Password: no longer store user password.
Replaced by x
UID: numerical user identification (unique)
GID: users numerical group identification
Comment or GCOS: user details
Home directory: default initial location when
logging in
Login shell: the first program executed after
logging in
/etc/shadow
For every line in /etc/passwd, theres a
corresponding entry in /etc/shadow

sn010101:2u6VExtjjXHFk:12285::::::

Password
Encryption
Adding a User
useradd command: add user to the system
Also creates users mailbox set MAIL variable
to point to /var/mail or /var/spool/mail

# useradd u 210 g dba c Surizal Nazeri \


d /home/sn010101 s /bin/ksh m sn010101

Options: -d: default initial location when logging in


-u: UID -s: Login shell
-g: GID -m: ensure create home directory
-c: Comment or GCOS
Modifying Users
usermod command: modify some of the
parameters set with useradd for example
login shell (/bin/bash)
# usermod surizal
Removing Users
userdel command: remove user from the
system including data in /etc/passwd and
/etc/group

Remove user
# userdel sn010101

Remove user together with their home directory


# userdel r sn010101
References

1. Das, S. (2012). Your UNIX/LINUX The Ultimate


Guide: Third Edition. McGraw-Hill
2. Hahn, H. (2008). Harley Hahn's Guide to Unix and
Linux. California: McGraw-Hill Higher Education

This teaching material belongs to:


Systems and Networking Department,
College of Information Technology,
Universiti Tenaga Nasional.

You might also like