Advanced User Management Labs
Lab: Set and Confirm Password Aging with chage (root)
- Set password aging parameters for user100 to mindays (-m) 7, maxdays (-M) 28, and warndays (-W) 5:
chage -m 7 -M 28 -W 5 user100
- Confirm
- Set the account expiry to January 31, 2020
chage -E 2020-01-31 user100
- Verify the new account expiry setting
Lab: Set and Confirm Password Aging with passwd (root)
- Set password aging attributes for user200 to mindays 10, maxdays 90, and warndays 14:
passwd -n 10 -x 90 -w 14 user200
- Confirm:
- Set the number of inactivity days to 5:
- Confirm:
- Ensure that the user is forced to change their password at next login:
- Confirm:
Lab: Lock and Unlock a User Account with usermod and passwd (root)
- Obtain the current password information for user200 from the shadow file:
- Lock the account for user200:
- Confirm:
- Unlock the account with either of the following:
usermod -U user200
or
passwd -u user200
- confirm
Lab: Create a Group and Add Members (root)
- Create the group linuxadm with GID 5000:
groupadd -g 5000 linuxadm
- Create a group called dba with the same GID as that of group linuxadm:
- Confirm:
grep linuxadm /etc/group
grep dba /etc/group
- Add user1 as a secondary member of group dba using the
usermod
command. The existing membership for the user must remain intact.
- Verify the updated group membership information for user1 by extracting the relevant entry from the group file, and running the id and groups command for user1:
grep dba /etc/group
id user1
groups user1
Lab: Modify and Delete a Group Account (root)
- Alter the name of linuxadm to sysadm:
groupmod -n sysadm linuxadm
- Change the GID of sysadm to 6000:
- Confirm:
grep sysadm /etc/group
grep linuxadm /etc/group
- Delete sysadm group and confirm:
groupdel sysadm
grep sysadm /etc/group
Lab: To switch from user1 (assuming you are logged in as user1) into root without executing the startup scripts
- switch to user100
- See what whoami and logname reports now:
- use su as follows and execute this privileged command to obtain desired results:
su -c 'firewall-cmd --list-services'
Lab: Add user1 to sudo file but only for the cat command.
- Open up /etc/sudoers and add the following:
- run cat as user1 with and without sudo:
cat /etc/sudoers
sudo cat /etc/sudoers
Lab: Add user and command aliases to the sudoer file.
- Add the following to the bottom of the sudoers file:
Cmnd_Alias PKGCMD = /usr/bin/yum, /usr/bin/rpm
User_Alias PKGADM = user1, user100, user200
PKGADM ALL=PKGCMD
- Run rpm or yum with sudo as one of the users.
Lab: Take a look at examples in the sudoers file.
- Create a file file1 as user1 in their home directory and exhibit the file’s long listing:
- View the corresponding UID and GID instead, you can specify the -n option with the command:
Lab: Modify File Owner and Owning Group
- Change into the /tmp directory and create file10 and dir10:
cd /tmp
touch file10
mkdir dir10
- Check and validate that both attributes are set to user1:
ls -l file10
ls -ld dir10
- Set the ownership of file10 to user100 and confirm:
sudo chown user100 file10
ls -l file10
- Alter the owning group to dba and verify:
sudo chgrp dba file10
ls -l file10
- Change the ownership to user200 and owning group to user100 and confirm:
sudo chown user200:user100 file10
- Modify the ownership to user200 and owning group to dba recursively on dir10 and validate:
sudo chown -R user200:dba dir10
ls -ld dir10
- Create group lnxgrp with GID 6000.
- Create user user5000 with UID 5000 and GID 6000. Assign this user a password.
useradd -u 5000 -g 6000 user5000
- Establish password aging attributes so that this user cannot change their password within 4 days after setting it and with a password validity of 30 days. This user should start getting warning messages for changing password 10 days prior to account lock down.
chage -m 4 -M 30 -W 10 user5000
- This user account needs to expire on the 20th of December, 2021.
chage -E 2021-12-20 user5000
Lab 6-2: Lock and Unlock User (root)
- Lock the user account for user5000 using the passwd command, and
- confirm by examining the change in the /etc/shadow file.
- Try to log in with user5000 and observe what happens.
- Use the usermod command and unlock