LFCS: Users and Groups (10%)
This section covers user and group management, environment profiles, ACLs, resource limits, and LDAP integration.
1. Create and Manage Local User Accounts
Learn
- Add, modify, and delete local users.
- Manage home directories and shells.
Commands
# Add user
sudo useradd -m -s /bin/bash username
sudo passwd username
# Modify user
sudo usermod -aG sudo username # Add to group
sudo usermod -d /new/home username # Change home directory
# Delete user
sudo userdel -r username # Delete user and home directory
Exercises
- Create a user with home directory and bash shell.
- Add the user to the sudo group.
- Remove a test user.
2. Create and Manage Groups
Learn
- Create, modify, and delete groups.
- Assign users to groups.
Commands
# Create group
sudo groupadd developers
# Modify group
sudo gpasswd -a username developers
# Delete group
sudo groupdel developers
# List groups
groups username
Exercises
- Create a group
adminsand add a user. - Verify the user is part of the group.
- Delete the group.
3. Manage Environment Profiles
Learn
- System-wide vs user-specific profiles.
- Configure PATH, variables, and shell startup files.
Commands
# Edit system-wide profile
sudo nano /etc/profile
sudo nano /etc/bash.bashrc
# Edit user profile
nano ~/.bashrc
source ~/.bashrc # Reload changes
Exercises
- Add a directory to PATH in
.bashrcand reload. - Set a custom environment variable system-wide.
4. Configure User Resource Limits
Learn
- Use
ulimitand/etc/security/limits.conffor limits on processes, open files, and memory.
Commands
# Temporary limit
ulimit -n 4096
# Persistent limit
sudo nano /etc/security/limits.conf
# user soft nofile 4096
# user hard nofile 8192
Exercises
- Increase the maximum number of open files for a user.
- Verify limits with
ulimit -a.
5. Configure and Manage ACLs (Access Control Lists)
Learn
- Set fine-grained permissions beyond standard Unix mode bits.
- Commands:
getfaclandsetfacl.
Commands
# Check ACL
getfacl /path/to/file
# Set ACL for user
setfacl -m u:username:rwx /path/to/file
# Remove ACL
setfacl -x u:username /path/to/file
Exercises
- Give read/write access to a specific file for a user without changing group ownership.
- Remove the ACL and verify permissions.
6. Configure the System to Use LDAP for Users and Groups
Learn
- Integrate Linux system with LDAP server for centralized authentication.
- Configure NSS and PAM.
Commands
# Install LDAP client
sudo apt install libnss-ldap libpam-ldap ldap-utils
# Configure /etc/nsswitch.conf
sudo nano /etc/nsswitch.conf
# passwd: files ldap
group: files ldap
shadow: files ldap
# Test LDAP user
getent passwd ldapuser
id ldapuser
Exercises
- Connect a Linux system to an LDAP server.
- Verify that LDAP users can login.
Exam Tips
- Practice creating users and groups both locally and via LDAP.
- Understand persistent vs temporary environment variable settings.
- Familiarize with ACL commands for fine-grained permission control.