This is part of the independent and unofficial RHCSA Exam Study Guide series providing free π€ resources to prepare for the exam.
This post covers the objectives under the section:
“MANAGE USERS AND GROUPS”
It contains two main parts:
- Resources: with links to learn and practice for each objective.
- Cheatsheet: containing some examples of commands and actions performed in each objective (when applied).
π Resources:
CREATE, DELETE, AND MODIFY LOCAL USER ACCOUNTS
π A Complete Guide to Usage of βusermodβ command β 15 Practical Examples with Screenshots
π Linux sysadmin basics: User account management with UIDs and GIDs
π 3 basic Linux user management commands every sysadmin should know
CHANGE PASSWORDS AND ADJUST PASSWORD AGING FOR LOCAL USER ACCOUNTS
π Forcing Linux system password changes with the chage command
π How to Manage User Password Expiration and Aging in Linux
CREATE, DELETE, AND MODIFY LOCAL GROUPS AND GROUP MEMBERSHIPS
CONFIGURE SUPERUSER ACCESS
π Cheatsheet:
CREATE, DELETE, AND MODIFY LOCAL USER ACCOUNTS
last
β‘ show a listing of last logged in users.lastb
β‘ show a listing of last unsuccessful log in/outs.lastlog
β‘ reports the most recent login of all users of a given user.who
β‘ show who is logged in.w
β‘ show who is logged in and what they are doing.id
β‘ print real and effective user and group IDs.getent passwd | grep usr1
β‘ displayusr1
definitions from/etc/passwd
file.usermod -G -a db user99
β‘ adddb
group as a suplementary group touser99
account.usermod -u 1010 user99
β‘ change user’s UID.usermod -d /home/user-99-new -m user99
β‘ change user’s home directory.useradd -s /sbin/nologin user99
β‘ createuser99
account with the disability of logging in.userdel -r user45
β‘ remove user and it’s home directory and mail spool.
CHANGE PASSWORDS AND ADJUST PASSWORD AGING FOR LOCAL USER ACCOUNTS
passwd user1
β‘ change user’s password.chage -l usr1
β‘ display account aging information.chage -m 1 -M 90 usr1
β‘ set minimum and maximum days before password change forusr1
.chage -d 2021-12-15 usr1
β‘ set the date of last password change.chage -W 10 -I 4 usr1
β‘usr1
passwd will warn 10 days prior to password expiration, and is set to lock the user 4 days after expiration.passwd -x 30 -n 4 -w 10 user1
β‘ user 1 password expires in 30 days, cannot change at least 4 days, starts warning 10 days prior to expiration.usermod -e 2021-12-20 user1
,chage -E 2022-12-15 user1
β‘ set password expiration date.passwd -S user1
β‘ report password status (expiration, etc).usermod -L user1
,passwd -l user1
β‘ lockuser1
account (verify the lock at/etc/shadow
file, there must be!!
prepending the password hash).Edit
PASS_MAX_DAYS 30
in/etc/login.defs
file β‘ set default password expiration limit to 30 days for the whole system.
CREATE, DELETE, AND MODIFY LOCAL GROUPS AND GROUP MEMBERSHIPS
groups
β‘ print the groups a user is in.getent group | grep db
β‘ displaydb
group definitions from/etc/group
file.groupadd mkt
β‘ createmkt
group.gpasswd -d user1 db
β‘ removesuser1
fromdb
group.groupmod -g 10400 mkt
β‘ change group’s GID.groupmod -n newmkt mkt
β‘ change group’s name.groupdel mkt
β‘ deletemkt
group.
CONFIGURE SUPERUSER ACCESS
visudo
β‘ edit the/etc/sudoers
file.su -l user40
β‘ login asuser40
.user1 ALL=(ALL) NOPASSWD: ALL
β‘ onsudoers
file gives full root access to the system without prompting for password.usermod -aG wheel user99
β‘ adduser99
towhell
group which has extended privileges.sudo -l -U usr1
β‘ verify if user hassudo
privileges.
Next:
(RHCSA) Manage Security
…or back to Red Hat Certified System Administrator (RHCSA) Exam Study Guide
Useful links & references:
Enable Sysadmin (a blog from Red Hat)
Footnotes:
- Follow me on Twitter to get more posts like this and other quick tips in your feed.
- If you have any doubts or tips about this article, Iβd appreciate knowing and discussing it via email.
- Do you have any other Linux tips? Would you like to publish that in this blog? Please send an email to all drops.
- As English is not my native language, I apologize for the errors. Corrections are welcome.
- Contact: contact [@] alldrops [.] info.