Skip to main content

User Management

useradd username

create a user

groupadd groupname

create a group

userdel username

delete user

groupdel groupname

delete group

usermod username

modify user

 

Important files

/etc/passwd

/etc/group

/etc/shadow

 

Examples

useradd -g superheros -s /bin/bash -c "User Description" -m -d /home/spiderman spiderman

(Creates spiderman in group superheros)

 

usermod -G superheros spiderman

(adds spiderman to superheros group)

 

chgrp -R superheros spiderman

(change the group owner of user to superheros)

 

cat /etc/passwd

display users, passwords (x=encrypted), UserID, GroupID, etc.

 

 

defaults file located in /etc/login.defs

Example:

chage -m 5 -M 90 -W 10 -I 3 -E 20656 babubutt

-d

(lastchanged) days since 01/01/1970 that password was last changed

-m

minimum number of days between password changes

-M

maximum number of days before user must change password

-W

number of days before password is to expire before user is warned

-I

number of days after password expires that account is disabled

-E

days since 01/01/1970 that account is disabled (account end date)

 

grep babu /etc/shadow

babubutt:!:20626:5:90:10:3:20656:

 

Switching users and sudo access

su -

switch to root

su - username

switch user

sudo

perform action as super user

visudo

 

 

Add user to sudoers

su -

switch to root

usermod -aG wheel nsotelo

adds nsotelo to wheel group

grep wheel /etc/group

verify

su - nsotelo

switch back to nsotelo

sudo fdisk -l

run sudo command to confirm access