0
0
Linux CLIscripting~20 mins

groups and group management in Linux CLI - Practice Problems & Coding Challenges

Choose your learning style9 modes available
Challenge - 5 Problems
🎖️
Group Mastery Badge
Get all challenges correct to earn this badge!
Test your skills under time pressure!
💻 Command Output
intermediate
1:30remaining
What is the output of the command to list all groups on the system?
You run the command cat /etc/group on a Linux system. What will this command output?
Linux CLI
cat /etc/group
AA list of all groups on the system with their members
BThe system's hostname
CThe current user's groups only
DA list of all user accounts on the system
Attempts:
2 left
💡 Hint
Think about where Linux stores group information.
💻 Command Output
intermediate
1:30remaining
What does the command groups username output?
You run groups alice on a Linux system. What output should you expect?
Linux CLI
groups alice
AAll groups on the system
BThe primary group of the user 'alice' only
CThe user's home directory path
DGroups that the user 'alice' belongs to
Attempts:
2 left
💡 Hint
This command shows group memberships for a specific user.
💻 Command Output
advanced
2:00remaining
What is the effect of the command sudo usermod -aG sudo alice?
You run sudo usermod -aG sudo alice. What does this command do?
Linux CLI
sudo usermod -aG sudo alice
ADeletes user 'alice' from the system
BAdds user 'alice' to the sudo group without removing existing groups
CChanges 'alice' primary group to sudo
DRemoves user 'alice' from the sudo group
Attempts:
2 left
💡 Hint
The -a and -G options together modify group membership.
💻 Command Output
advanced
2:00remaining
What error occurs when running sudo usermod -G sudo alice if 'alice' is already in groups 'users' and 'staff'?
You run sudo usermod -G sudo alice but 'alice' was previously in groups 'users' and 'staff'. What happens?
Linux CLI
sudo usermod -G sudo alice
AUser 'alice' is removed from 'users' and 'staff' groups and only in 'sudo'
BUser 'alice' is added to sudo group and keeps all previous groups
CCommand fails with syntax error
DUser 'alice' is deleted
Attempts:
2 left
💡 Hint
The -G option without -a replaces group memberships.
🚀 Application
expert
3:00remaining
Write a script snippet to add a user to multiple groups safely without removing existing groups
You want to add user 'bob' to groups 'docker' and 'video' without removing his current groups. Which script snippet achieves this correctly?
Asudo usermod -a -G docker -G video bob
Bsudo usermod -G docker,video bob
Csudo usermod -aG docker,video bob
Dsudo usermod -aG docker bob && sudo usermod -aG video bob
Attempts:
2 left
💡 Hint
The -G option accepts a comma-separated list, but appending multiple times requires separate commands.