diff --git a/src/SUMMARY.md b/src/SUMMARY.md index b800a9c..4b81823 100644 --- a/src/SUMMARY.md +++ b/src/SUMMARY.md @@ -7,11 +7,13 @@ - [RHCSA](rhcsa.md) # Practice Scenarios +- [Overview](practice-scenarios/README.md) - [Practice Scenarios v1](practice-scenarios/rhcsa_practice_scenarios.md) - [Practice Scenarios v2](practice-scenarios/rhcsa_practice_scenarios_v2.md) - [Practice Scenarios v3](practice-scenarios/rhcsa_practice_scenarios_v3.md) - [Practice Scenarios v4](practice-scenarios/rhcsa_practice_scenarios_v4.md) - [Practice Scenarios v5](practice-scenarios/rhcsa_practice_scenarios_v5.md) +- [Mock RHCSA Exam](practice-scenarios/mock-rhcsa-exam.md) # My Solutions Portfolio - [Portfolio Overview](solutions/README.md) @@ -23,3 +25,4 @@ - [Container Management Solutions [📦]](solutions/container-management.md) - [System Recovery Solutions [🔧]](solutions/system-recovery.md) - [Shell Scripting Solutions [📜]](solutions/shell-scripting.md) +- [Mock Exam Solutions [🎯]](solutions/mock-exam-solutions.md) diff --git a/src/practice-scenarios/README.md b/src/practice-scenarios/README.md new file mode 100644 index 0000000..1290972 --- /dev/null +++ b/src/practice-scenarios/README.md @@ -0,0 +1,26 @@ +# RHCSA Practice Scenarios + +This directory contains various practice scenarios and a mock exam to help prepare for the Red Hat Certified System Administrator (RHCSA) exam. + +## Available Practice Materials + +- **Practice Scenarios v1-v5**: Incremental practice scenarios covering individual RHCSA objectives +- **Mock RHCSA Exam**: A comprehensive mock exam that simulates the actual RHCSA exam environment and tasks + +## How to Use These Materials + +1. Start with the practice scenarios to build specific skills +2. Once comfortable with individual components, attempt the mock exam +3. Time yourself to simulate exam conditions (2.5 hours) +4. Review and practice areas where you struggled + +## Key Focus Areas + +- User and group management +- Storage configuration (partitions, LVM, STRATIS) +- Service management and automation +- Network configuration +- Security (firewall, SELinux) +- Container management + +Remember that the actual RHCSA exam is performance-based, so hands-on practice in a lab environment is essential for success. \ No newline at end of file diff --git a/src/practice-scenarios/mock-rhcsa-exam.md b/src/practice-scenarios/mock-rhcsa-exam.md new file mode 100644 index 0000000..6b1958d --- /dev/null +++ b/src/practice-scenarios/mock-rhcsa-exam.md @@ -0,0 +1,117 @@ +# Mock RHCSA (EX200) Practice Exam + +## Introduction + +This mock exam is designed to help you prepare for the Red Hat Certified System Administrator (RHCSA) exam (EX200). It covers the key objectives outlined in the official exam requirements and will test your practical skills in system administration. + +**Exam Guidelines:** +- Duration: 2.5 hours (just like the real exam) +- All tasks must be completed within the allotted time +- Your configurations must persist after reboot +- You may reference Red Hat documentation included with the system + +**Exam Environment:** +- Red Hat Enterprise Linux 9 +- Virtual machine with 4GB RAM, 20GB disk space +- Internet access is NOT available during the exam +- Root access is available + +## Exam Tasks + +### Task 1: Essential Tools and User Management +1. Create a user named `analyst` with UID 2525 +2. Set the password for `analyst` to `RedHat123` +3. The password should expire after 90 days +4. Create a group named `research` with GID 3535 +5. Add the `analyst` user to the `research` group as a secondary group +6. Create a directory `/data/research` owned by `analyst` with group ownership set to `research` +7. Set special permissions on the directory so that all files created in `/data/research` will automatically be owned by the `research` group + +### Task 2: File Management and Permissions +1. Create a file `/data/research/readme.txt` with the content "Research data repository" +2. Set permissions on `/data/research/readme.txt` so that: + - The owner has read and write permissions + - The group has read-only permissions + - Others have no permissions +3. Create a hard link named `/home/analyst/data-link` to the readme.txt file +4. Create a soft link named `/home/analyst/data-symlink` to the `/data/research` directory + +### Task 3: Storage Configuration +1. Create a 1GB partition on the available disk (check with `lsblk` for available space) +2. Create a volume group named `vg_data` using the partition you created +3. Create a 500MB logical volume named `lv_data` in the `vg_data` volume group +4. Format the logical volume with the XFS filesystem +5. Mount the filesystem at `/mnt/data` permanently (should persist after reboot) +6. Create a 256MB swap partition and enable it permanently + +### Task 4: Configure STRATIS Storage +1. Install the STRATIS storage management tools +2. Create a 1GB partition on the available disk +3. Create a STRATIS pool named `pool1` using the partition +4. Create a filesystem named `fs1` in the STRATIS pool +5. Mount the filesystem at `/mnt/stratis` permanently + +### Task 5: Container Management +1. Install the container tools (podman) +2. Find and pull the latest httpd container image +3. Run a container named `webserver` using the httpd image with the following specifications: + - The container should be accessible on port 8080 of the host + - The container should start automatically when the system boots + - Create a simple HTML file with the content "RHCSA Practice Exam" accessible through the web server + +### Task 6: Service Configuration +1. Install and configure the chronyd service to synchronize time with `time.nist.gov` +2. Configure the chronyd service to start automatically on boot +3. Configure the system to use the timezone America/New_York + +### Task 7: System Management +1. Configure the system to boot into the multi-user target by default +2. Create a scheduled task using cron for the `analyst` user that creates a backup of `/etc/passwd` to `/home/analyst/passwd.bak` every day at 3:00 AM +3. Create a systemd timer that runs a script to check disk space and writes the output to `/var/log/diskspace.log` every hour + +### Task 8: Networking Configuration +1. Configure the network interface with the following settings: + - IP address: 192.168.1.100/24 + - Gateway: 192.168.1.1 + - DNS server: 8.8.8.8 + - DNS search domain: example.com +2. The configuration should persist after reboot +3. Configure the hostname as `rhcsa-exam` + +### Task 9: Security Configuration +1. Configure the firewall to allow HTTP (port 80) and HTTPS (port 443) traffic +2. Configure SELinux to allow the web server to connect to the network +3. Set up SSH key-based authentication for the `analyst` user +4. Configure the system to prevent the root user from logging in via SSH + +### Task 10: Storage Expansion +1. Extend the logical volume `lv_data` to 750MB +2. Extend the corresponding XFS filesystem to use the additional space +3. Verify that the filesystem is successfully expanded and functioning correctly + +### Task 11: Bash Scripting +1. Create a script named `/usr/local/bin/system_info.sh` that: + - Displays the current system time + - Shows the system hostname + - Lists the current disk usage + - Shows current memory usage +2. Make the script executable +3. Ensure the script runs properly when called without a full path + +### Task 12: NFS Configuration +1. Configure the system as an NFS server exporting `/mnt/data` to 192.168.1.0/24 with read-write access +2. Configure the firewall to allow NFS traffic +3. Start the NFS service and ensure it starts automatically on boot + +## Scoring Guide + +Each task has approximately equal weight. To pass this mock exam (like the real RHCSA), you need to successfully complete 70% of the tasks. + +After completing the exam, test your configurations by: +1. Rebooting the system to verify persistence +2. Logging in as the created users +3. Verifying services are running correctly +4. Checking that mounted filesystems are accessible +5. Testing that the container is accessible + +Good luck with your practice! \ No newline at end of file diff --git a/src/solutions/mock-exam-solutions.md b/src/solutions/mock-exam-solutions.md new file mode 100644 index 0000000..6dc52d2 --- /dev/null +++ b/src/solutions/mock-exam-solutions.md @@ -0,0 +1,318 @@ +# Mock RHCSA Exam - Solutions + +This document provides solutions for the [Mock RHCSA Exam](../practice-scenarios/mock-rhcsa-exam.md). Use these solutions to check your work after attempting the exam yourself. + +## Task 1: Essential Tools and User Management + +```bash +# Create user with specific UID +sudo useradd -u 2525 analyst + +# Set password and expiration +sudo passwd analyst +# Enter RedHat123 when prompted +sudo chage -M 90 analyst + +# Create group with specific GID +sudo groupadd -g 3535 research + +# Add user to group as secondary +sudo usermod -aG research analyst + +# Create directory with proper ownership +sudo mkdir -p /data/research +sudo chown analyst:research /data/research + +# Set SGID bit on directory +sudo chmod g+s /data/research +``` + +## Task 2: File Management and Permissions + +```bash +# Create file with content +echo "Research data repository" | sudo tee /data/research/readme.txt + +# Set permissions +sudo chmod 640 /data/research/readme.txt + +# Create hard link +sudo ln /data/research/readme.txt /home/analyst/data-link + +# Create soft link +sudo ln -s /data/research /home/analyst/data-symlink +``` + +## Task 3: Storage Configuration + +```bash +# Check available disks +lsblk + +# Create partition (assuming /dev/sdb is available) +sudo fdisk /dev/sdb +# n (new), p (primary), 1 (partition number), enter (default), +1G, w (write) + +# Create volume group +sudo vgcreate vg_data /dev/sdb1 + +# Create logical volume +sudo lvcreate -L 500M -n lv_data vg_data + +# Format with XFS +sudo mkfs.xfs /dev/vg_data/lv_data + +# Create mount point +sudo mkdir /mnt/data + +# Add to fstab for persistence +echo "/dev/vg_data/lv_data /mnt/data xfs defaults 0 0" | sudo tee -a /etc/fstab + +# Mount +sudo mount -a + +# Create swap partition (assuming /dev/sdc is available) +sudo fdisk /dev/sdc +# n (new), p (primary), 1 (partition number), enter (default), +256M, t (type), 82 (swap), w (write) + +# Format as swap +sudo mkswap /dev/sdc1 + +# Add to fstab +echo "/dev/sdc1 none swap defaults 0 0" | sudo tee -a /etc/fstab + +# Enable swap +sudo swapon -a +``` + +## Task 4: Configure STRATIS Storage + +```bash +# Install STRATIS tools +sudo dnf install -y stratisd stratis-cli + +# Create partition (assuming /dev/sdd is available) +sudo fdisk /dev/sdd +# n (new), p (primary), 1 (partition number), enter (default), +1G, w (write) + +# Start STRATIS service +sudo systemctl enable --now stratisd + +# Create STRATIS pool +sudo stratis pool create pool1 /dev/sdd1 + +# Create filesystem +sudo stratis filesystem create pool1 fs1 + +# Create mount point +sudo mkdir /mnt/stratis + +# Add to fstab (get UUID first) +STRATIS_UUID=$(sudo stratis filesystem list | grep fs1 | awk '{print $4}') +echo "UUID=${STRATIS_UUID} /mnt/stratis xfs defaults,x-systemd.requires=stratisd.service 0 0" | sudo tee -a /etc/fstab + +# Mount filesystem +sudo mount -a +``` + +## Task 5: Container Management + +```bash +# Install container tools +sudo dnf install -y podman + +# Pull httpd image +sudo podman pull httpd:latest + +# Create directory for web content +sudo mkdir -p /var/www/html + +# Create HTML file +echo "

RHCSA Practice Exam

" | sudo tee /var/www/html/index.html + +# Run container +sudo podman run -d --name webserver -p 8080:80 -v /var/www/html:/usr/local/apache2/htdocs:Z httpd:latest + +# Create systemd service for auto-start +sudo mkdir -p /etc/systemd/system +sudo podman generate systemd --name webserver --files --new + +# Copy and enable the service +sudo cp container-webserver.service /etc/systemd/system/ +sudo systemctl enable --now container-webserver.service +``` + +## Task 6: Service Configuration + +```bash +# Install chronyd if not already installed +sudo dnf install -y chrony + +# Configure chrony +sudo sed -i 's/^pool.*/server time.nist.gov iburst/' /etc/chrony.conf + +# Enable and start service +sudo systemctl enable --now chronyd + +# Set timezone +sudo timedatectl set-timezone America/New_York +``` + +## Task 7: System Management + +```bash +# Set default target to multi-user +sudo systemctl set-default multi-user.target + +# Create cron job for analyst +sudo -u analyst crontab -e +# Add: 0 3 * * * cp /etc/passwd /home/analyst/passwd.bak + +# Create systemd timer for disk space check +cat << 'EOF' | sudo tee /usr/local/bin/disk_check.sh +#!/bin/bash +df -h > /var/log/diskspace.log +EOF + +sudo chmod +x /usr/local/bin/disk_check.sh + +# Create service file +cat << 'EOF' | sudo tee /etc/systemd/system/disk-check.service +[Unit] +Description=Check disk space + +[Service] +Type=oneshot +ExecStart=/usr/local/bin/disk_check.sh +EOF + +# Create timer file +cat << 'EOF' | sudo tee /etc/systemd/system/disk-check.timer +[Unit] +Description=Run disk space check hourly + +[Timer] +OnBootSec=1min +OnUnitActiveSec=1h + +[Install] +WantedBy=timers.target +EOF + +# Enable and start timer +sudo systemctl enable --now disk-check.timer +``` + +## Task 8: Networking Configuration + +```bash +# Configure network interface (assuming interface name is eth0) +sudo nmcli connection add con-name static-eth0 ifname eth0 type ethernet ip4 192.168.1.100/24 gw4 192.168.1.1 +sudo nmcli connection modify static-eth0 ipv4.dns "8.8.8.8" +sudo nmcli connection modify static-eth0 ipv4.dns-search "example.com" +sudo nmcli connection up static-eth0 + +# Set hostname +sudo hostnamectl set-hostname rhcsa-exam +``` + +## Task 9: Security Configuration + +```bash +# Configure firewall +sudo firewall-cmd --permanent --add-service=http +sudo firewall-cmd --permanent --add-service=https +sudo firewall-cmd --reload + +# Configure SELinux boolean for web server +sudo setsebool -P httpd_can_network_connect on + +# Set up SSH key-based authentication for analyst +sudo -u analyst mkdir -p /home/analyst/.ssh +sudo -u analyst chmod 700 /home/analyst/.ssh +sudo -u analyst ssh-keygen -t rsa -f /home/analyst/.ssh/id_rsa -N "" +sudo -u analyst cat /home/analyst/.ssh/id_rsa.pub >> /home/analyst/.ssh/authorized_keys +sudo -u analyst chmod 600 /home/analyst/.ssh/authorized_keys + +# Prevent root SSH login +sudo sed -i 's/^#PermitRootLogin yes/PermitRootLogin no/' /etc/ssh/sshd_config +sudo systemctl restart sshd +``` + +## Task 10: Storage Expansion + +```bash +# Extend logical volume +sudo lvextend -L 750M /dev/vg_data/lv_data + +# Extend XFS filesystem +sudo xfs_growfs /mnt/data + +# Verify expansion +df -h /mnt/data +``` + +## Task 11: Bash Scripting + +```bash +# Create script +cat << 'EOF' | sudo tee /usr/local/bin/system_info.sh +#!/bin/bash + +echo "Current system time: $(date)" +echo "System hostname: $(hostname)" +echo "Disk usage:" +df -h +echo "Memory usage:" +free -h +EOF + +# Make executable +sudo chmod +x /usr/local/bin/system_info.sh + +# Test script +system_info.sh +``` + +## Task 12: NFS Configuration + +```bash +# Install NFS server +sudo dnf install -y nfs-utils + +# Create exports file entry +echo "/mnt/data 192.168.1.0/24(rw,sync)" | sudo tee -a /etc/exports + +# Start and enable NFS server +sudo systemctl enable --now nfs-server + +# Configure firewall +sudo firewall-cmd --permanent --add-service=nfs +sudo firewall-cmd --permanent --add-service=rpc-bind +sudo firewall-cmd --permanent --add-service=mountd +sudo firewall-cmd --reload +``` + +## Verification Steps + +```bash +# Reboot to verify configurations persist +sudo reboot + +# Test user login +su - analyst + +# Test services +systemctl status chronyd +systemctl status stratisd +systemctl status nfs-server +systemctl status container-webserver.service + +# Test file systems +df -h +ls -la /mnt/data +ls -la /mnt/stratis + +# Test container +curl http://localhost:8080 +``` \ No newline at end of file