Files
it-knowledge/src/solutions/user-management.md
T

115 lines
3.3 KiB
Markdown
Raw Normal View History

2025-02-20 19:38:02 -06:00
# User Management Solutions
This section contains my solutions to various user management scenarios from the practice exercises.
## Scenario: Creating Users with Specific Requirements
### Original Problem
From Practice Scenarios v3: Create a user named 'john' with a custom shell and home directory.
### Environment
- OS Version: Rocky Linux 8.x
- Initial State: No user 'john' exists
- Required Outcome: User 'john' created with specific requirements
### Solution Steps
1. Create the user with specific requirements
```bash
# Create user with custom home directory
sudo useradd -m -d /custom/home/john -s /bin/bash john
# Set password
sudo passwd john
```
This creates the user 'john' with a custom home directory and bash shell
2. Verify user creation
```bash
# Check user entry in /etc/passwd
grep john /etc/passwd
# Verify home directory
ls -la /custom/home/john
```
### Key Learnings
- Understanding of useradd command options
- Importance of verifying user creation
- Best practices for user management
## Skills Demonstrated
- User Account Management
- Command Line Proficiency
- Security Best Practices
- System Verification
2025-02-20 23:07:39 -06:00
***
***
# Scenario: Creating Users with Specific Requirements
## Original Problem
- Create a new user called 'analyst1' with home directory '/home/analyst1'
- Create a group called 'datateam'
- Add 'analyst1' to 'datateam'
- Create a directory '/data/reports' owned by 'datateam' with SGID set
- Ensure members of 'datateam' can read/write, others can only read
- Set password expiry for 'analyst1' to 90 days
## Environment
- OS Version: RHEL 9.5
- Initial State: No user 'analyst1' exists
- Required Outcome: User 'analyst1' created with specific requirements
## Solution Steps
1. Step 1 - Create the user 'analyst1'
```bash
sudo useradd -m -d /home/analyst1 analyst1
```
This creates the user 'analyst1' with a home directory '/home/analyst1'
2. Step 2
```bash
sudo groupadd datateam
```
This creates the group 'datateam'
3. Step 3 - Add 'analyst1' to 'datateam'
```bash
sudo usermod -aG datateam analyst1
```
This adds 'analyst1' to the 'datateam' group
4. Step 4 - Create the directory '/data/reports' owned by 'datateam' with SGID set
```bash
sudo mkdir -p /data/reports
sudo chown :datateam /data/reports
sudo chmod 2775 /data/reports
```
This creates the directory '/data/reports' owned by 'datateam' with SGID set
5. Step 5 - Ensure members of 'datateam' can read/write, others can only read
```bash
sudo chmod 2775 /data/reports
```
This ensures members of 'datateam' can read/write, others can only read
6. Step 6 - Set password expiry for 'analyst1' to 90 days
```bash
sudo chage -E $(date -d '90 days' +%Y-%m-%d) analyst1
```
This sets the password expiry for 'analyst1' to 90 days
## Verification
Commands used to verify the solution works correctly
## Key Learnings
- Understanding of useradd, groupadd, usermod, mkdir, chown, chmod, chage commands
- Importance of verifying user creation
- Importance of setting password expiry
## Additional Notes
> [!NOTE]
> This scenario is a good example of how to create a user with a specific home directory, add them to a group, create a directory owned by the group with SGID set, and set password expiry.