updated solutions for practice scenerios
This commit is contained in:
@@ -43,4 +43,72 @@ From Practice Scenarios v3: Create a user named 'john' with a custom shell and h
|
||||
- Security Best Practices
|
||||
- System Verification
|
||||
|
||||
[Additional scenarios will be documented here as they are completed]
|
||||
***
|
||||
***
|
||||
|
||||
# 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.
|
||||
|
||||
|
||||
Reference in New Issue
Block a user