User Management

User management :

Whenever user is added to system, information regarding the same is stored in

three main files which are

/etc/passwd :- Account information

/etc/shadow :- stores encrypted password

/etc/group :- stores groups information

Lets get practical and get started with basi command for adding user

useradd : adds user to the system, entry of the account is made in the

/etc/passwd file and password for the account is stored in password /etc/shadow

Example :

Lets look how the entry is stored in /etc/passwd file

bash# cat /etc/passwd

root:x:0:1:Super-User:/:/sbin/sh

daemon:x:1:1::/:

bin:x:2:2::/usr/bin:

sys:x:3:3::/:

adm:x:4:4:Admin:/var/adm:

lp:x:71:8:Line Printer Admin:/usr/spool/lp:

uucp:x:5:5:uucp Admin:/usr/lib/uucp:

nuucp:x:9:9:uucp Admin:/var/spool/uucppublic:/usr/lib/uucp/uucico

smmsp:x:25:25:SendMail Message Submission Program:/:

listen:x:37:4:Network Admin:/usr/net/nls:

nobody:x:60001:60001:Nobody:/:

noaccess:x:60002:60002:No Access User:/:

nobody4:x:65534:65534:SunOS 4.x Nobody:/:

Each of those file are

loginname:x:UID:GID:comment:home_directory:login_shell

where x specfied the password is encrypted and stored in /etc/shadow file

UID is the user-id of the user, GID is the group id

Note :

account file i.e /etc/passwd file can be read by anyone

however /etc/shadow can be read by only root

Now the user has been created you could create password for it by using 'passwd command

bash# passwd user1

after that it prompts for password, which is then encrypted and stored in /etc/shadow

If we were to modify setting for existing users, we have following commands

useradd : Adds a new user account to the local system

usermod : Modifies a user’s account on the local system

userdel : Deletes a user’s account from the local system

Groups

/etc/group : Stores the information regarding the groups configured on the system.

# cat /etc/group

root::0:root

other::1:

bin::2:root,bin,daemon

sys::3:root,bin,sys,adm

adm::4:root,adm,daemon

uucp::5:root,uucp

mail::6:root

tty::7:root,tty,adm

lp::8:root,lp,adm

nuucp::9:root,nuucp

staff::10:

daemon::12:root,daemon

sysadmin::14:lister,torey

nobody::60001:

noaccess::60002:

nogroup::65534:

#

Lets look at each field

<group name>:<optional password>:<GID>:<comma delimited members >

Commands

groupadd : Adds (creates) a new group account on the system

groupmod : Modifies a group account on the system

groupdel : Deletes a group account from the system