- Lab
-
Libraries: If you want this lab, consider one of these libraries.
- Cloud
- Security
Managing User and Group Accounts
The ability to manage user accounts and group membership is a crucial tool in any system administrator's box. In this hands-on lab, we will work with commands like `useradd`, `passwd`, `usermod`, `groupadd`, `groupmod` and `groupdel`. By the time we're done, we will have a good grasp on how to use these tools for managing user accounts and groups on any Linux system.
Lab Info
Table of Contents
-
Challenge
Create a tester Group in the Reserved Range
Use the
groupaddcommand with the-roption to create the grouptesters:groupadd -r tester -
Challenge
Add the test1 User and Make Them a Member of the tester Group. Lock and unlock the test1 User, and Force them to Change their Password
Use the command
useraddwith the-Goption to spection thetestergroup:useradd -G tester test1Set a temporary password (that the user will have to change the first time they log in):
echo Temp@$$ | passwd --stdin test1We could also set one manually by just running
passwd test1and typing/confirming a password by hand.Lock and unlock the account using the
usermodcommand.usermod -L test1 tail -n1 /etc/passwd /etc/shadow usermod -U test1We can run
tail -n1 /etc/passwd /etc/shadowto see if it got set.And to make
test1change their password on the next login, run:chage -d0 test1Verify the account and groups using the
idcommand.id test1 -
Challenge
Modify cloud_user to Add Secondary Membership in tester Group
Use the
usermodcommand with the-aGoptions to addcloud_userto thetestergroup:usermod -aG tester cloud_userWe can run
id cloud_userto check our work and see if the user is in the group now. -
Challenge
Create the /usr/local/test_scripts Directory Owned by cloud_user and Set GID Permission for the testers Group with No Access to Others
Create the directory:
mkdir /usr/local/test_scriptsMake sure it's owned by
cloud_user, and thetestergroup:chown cloud_user:tester /usr/local/test_scriptsGive the group write permissions, and revoke any permissions from anyone else:
chmod g+ws,o-rx /usr/local/test_scriptsAs a best practice, verify your work. Become the new user, get into the new directory, and create a couple things to look at:
su - test1 cd /usr/local/test_scripts mkdir dir1 touch file1 ls -l
About the author
Real skill practice before real-world application
Hands-on Labs are real environments created by industry experts to help you learn. These environments help you gain knowledge and experience, practice without compromising your system, test without risk, destroy without fear, and let you learn from your mistakes. Hands-on Labs: practice your skills before delivering in the real world.
Learn by doing
Engage hands-on with the tools and technologies you’re learning. You pick the skill, we provide the credentials and environment.
Follow your guide
All labs have detailed instructions and objectives, guiding you through the learning process and ensuring you understand every step.
Turn time into mastery
On average, you retain 75% more of your learning if you take time to practice. Hands-on labs set you up for success to make those skills stick.