Filters
How to search
  • Plain words find names, texts and examples.
  • "two words" finds the exact phrase.
  • --name or -x finds an option.
  • #word looks only inside commands.
  • @grep finds lessons and labs that use grep.
  • Filters: cat:network · in:labs · in:notes · level:rhcsa · ch:8 · root:yes. Put ! before a word to leave it out. OR between words means one of them.
  • ↑ ↓ to move · Enter to open · Esc to close · / to search

Lab 6.1RHCSA 10, Chapter 6

Create users and groups with password rules

Level
Easy
30 min
Machines
server1
Status
Not started

Goal

Set the defaults for new accounts, then create a small team with groups, password rules and one service account.

Before you start

  • Work on server1 as root (sudo -i).
  • This is a lab: you may use the password password for every user.

Tasks

  1. Make sure that every new user must change the password every 90 days and gets a file WELCOME.txt in the home folder.
  2. Create the group sales with GID 3000 and the group account.
  3. Create the users anna and bob. Both are members of sales; bob is also a member of account. Set a password for both.
  4. Create the user carol with the shell /sbin/nologin and no extra groups. Set a password.
  5. The account of bob must expire on 31 December 2026.
  6. anna must choose a new password at her next login.
  7. Lock the password of carol.
  8. Add anna to the group account without removing her from sales.

Check your work

id anna; id bob; id carol
getent group sales account
chage -l bob | grep 'Account expires'
chage -l anna | head -2
passwd -S carol
ls /home/anna
  • anna and bob are in sales and account; carol is only in her own group.
  • sales has GID 3000.
  • bob: Account expires Dec 31, 2026. anna: "password must be changed".
  • passwd -S carol shows L (locked). /home/anna has WELCOME.txt.
  • grep PASS_MAX_DAYS /etc/login.defs shows 90.

Hints

Show the hints

Solution

Show the solution
  1. Set the defaults first.
    sed -i 's/^PASS_MAX_DAYS.*/PASS_MAX_DAYS   90/' /etc/login.defs
    echo "Welcome to the team" > /etc/skel/WELCOME.txt
  2. Create the groups.
    groupadd -g 3000 sales
    groupadd account
  3. Create anna and bob and set the passwords.
    useradd -G sales anna
    useradd -G sales,account bob
    echo password | passwd --stdin anna
    echo password | passwd --stdin bob
  4. Create carol.
    useradd -s /sbin/nologin carol
    passwd carol
  5. Expire date for bob.
    chage -E 2026-12-31 bob
  6. Force a new password for anna.
    chage -d 0 anna
  7. Lock carol.
    passwd -l carol
  8. Add the extra group to anna.
    usermod -aG account anna

My notes

No notes yet.

Lessons for this lab

Commands in this lab