This task focuses on setting up system monitoring on an AWS EC2 instance to track CPU, memory, and disk usage, ensuring optimal performance.
- Go to AWS Console → EC2 → Launch Instance
- Select Ubuntu Server 24.04 LTS (HVM), EBS General Purpose (SSD)
- Choose Instance Type:
t2.micro(Free Tier) - Configure the Security Group:
- Allow SSH (port 22) from My IP
- Allow ICMP (All Traffic) for monitoring
- Configure Storage:
- Root Volume (10GB, GP3 SSD) →
/ - Log Volume (5GB, GP3 SSD) →
/var/logs/monitoring
- Root Volume (10GB, GP3 SSD) →
- Click Launch, create a new key pair (
my-key.pem), and download it.
- Open Git Bash (Windows) / Terminal (Mac/Linux)
- Move to the key’s location and set permissions:
chmod 400 my-key.pem
- Connect via SSH:
ssh -i my-key.pem ubuntu@<your-instance-ip>
- Update package lists:
sudo apt update && sudo apt upgrade -y - Install monitoring tools:
sudo apt install -y htop nmon
- Verify installation:
htop nmon
- Check disk usage:
df -h du -sh /var/log
- Check CPU & Memory usage:
free -m top
- Create the script:
sudo nano /usr/local/bin/system_monitor.sh
- Add the following:
#!/bin/bash echo "System Monitoring Report - $(date)" >> /var/logs/monitoring/system_monitor.log echo "CPU Usage:" >> /var/logs/monitoring/system_monitor.log top -bn1 | head -n 10 >> /var/logs/monitoring/system_monitor.log echo "Disk Usage:" >> /var/logs/monitoring/system_monitor.log df -h >> /var/logs/monitoring/system_monitor.log echo "Memory Usage:" >> /var/logs/monitoring/system_monitor.log free -m >> /var/logs/monitoring/system_monitor.log echo "-------------------------" >> /var/logs/monitoring/system_monitor.log
- Save & Exit (
Ctrl + X → Y → Enter). - Give execute permissions:
sudo chmod +x /usr/local/bin/system_monitor.sh
- Open crontab:
crontab -e
- Add this line at the bottom (runs every 5 minutes):
*/5 * * * * /usr/local/bin/system_monitor.sh
- Save & Exit.
- Check if the script runs:
cat /var/logs/monitoring/system_monitor.log
- Check cron jobs running:
sudo grep CRON /var/log/syslog
git config --global user.name "your-github-username"
git config --global user.email "your-email@example.com"mkdir -p ~/aws-monitoring-task
cd ~/aws-monitoring-task
git initsudo mv /usr/local/bin/system_monitor.sh ~/aws-monitoring-task/
sudo mv /var/logs/monitoring/system_monitor.log ~/aws-monitoring-task/git add .
git commit -m "Added system monitoring setup"
git remote add origin git@github.com:your-username/aws-devops-setup.git
git branch -M main
git push -u origin mainexit # To disconnect from EC2- Go to AWS Console → EC2 → Select Instance → Actions → Instance State → Stop
This completes the System Monitoring Setup. 🚀
Welcome to Task 2, where we transform an open system into a secure and structured workspace! Your challenge? Onboard new developers, lock down access, and enforce security policies to maintain a rock-solid environment.
👥 New Users: Sarah & Mike
📂 Goal: Assign them isolated, secure workspaces
🔐 Security Focus: Strong passwords & controlled access
First, let’s create Sarah and Mike as system users:
sudo useradd -m -c "Sarah Tessera, Developer" -s /bin/bash sarah
sudo useradd -m -c "Mike Alam, Developer" -s /bin/bash mike 🔥 Set secure passwords:
sudo passwd sarah
sudo passwd mike Each developer needs a private workspace to keep their work secure.
sudo mkdir -p /home/sarah/workspace
sudo mkdir -p /home/mike/workspace Assign ownership to the respective users:
sudo chown sarah:sarah /home/sarah/workspace
sudo chown mike:mike /home/mike/workspace 🚧 Locking down access (only the owner can access their directory):
sudo chmod 700 /home/sarah/workspace
sudo chmod 700 /home/mike/workspace To maintain security, enforce password complexity and expiration rules:
Edit password policy configuration:
sudo nano /etc/security/pwquality.confAdd or modify the following lines:
minlen = 12 # Minimum password length
dcredit = -1 # At least one digit
ucredit = -1 # At least one uppercase letter
lcredit = -1 # At least one lowercase letter
ocredit = -1 # At least one special character
retry = 3 # Allow 3 retries before failure
💾 Save and exit (CTRL + X → Y → ENTER)
Ensure passwords expire every 30 days:
sudo chage -M 30 sarah
sudo chage -M 30 mike Check expiration settings:
sudo chage -l sarah
sudo chage -l mike 🎯 Sarah and Mike now have:
✔️ Secure accounts
✔️ Private workspaces
✔️ Strong password policies
🔒 Security is not an option—it's a necessity! 🚀
Here is your README file formatted like the image:
Here is the complete README for Task 3 in the requested format:
Welcome to Task 3, where we ensure data integrity and recovery by configuring automated backups for web servers. Your challenge? Implement a scheduled backup system to protect critical web server files.
👩💻 Users: Sarah & Mike
🎯 Goal: Automate backups for their respective web servers
🔐 Security Focus: Reliable, verifiable backups & secure storage
First, let's create backup scripts for Sarah’s Apache server and Mike’s Nginx server.
📌 Apache Backup Script:
#!/bin/bash
# Apache Backup Script
timestamp=$(date +'%Y-%m-%d')
backup_file="/backups/apache_backup_$timestamp.tar.gz"
tar -czf $backup_file /etc/httpd/ /var/www/html/
echo "Apache backup created: $backup_file" >> /var/log/apache_backup.log📌 Nginx Backup Script:
#!/bin/bash
# Nginx Backup Script
timestamp=$(date +'%Y-%m-%d')
backup_file="/backups/nginx_backup_$timestamp.tar.gz"
tar -czf $backup_file /etc/nginx/ /usr/share/nginx/html/
echo "Nginx backup created: $backup_file" >> /var/log/nginx_backup.log✅ Set executable permissions:
chmod +x apache_backup.sh
chmod +x nginx_backup.sh Schedule backups to run every Tuesday at 12:00 AM by adding these lines to the crontab (crontab -e):
0 0 * * 2 /path/to/apache_backup.sh >> /var/log/apache_backup.log 2>&1
0 0 * * 2 /path/to/nginx_backup.sh >> /var/log/nginx_backup.log 2>&1 Backup files are saved in the /backups/ directory using this format:
apache_backup_YYYY-MM-DD.tar.gz
nginx_backup_YYYY-MM-DD.tar.gz
Example:
/backups/apache_backup_2025-03-19.tar.gz
/backups/nginx_backup_2025-03-19.tar.gz
After a scheduled backup, check if backup files exist:
ls -lh /backups/ Verify the contents of the backup:
tar -tzf /backups/apache_backup_YYYY-MM-DD.tar.gz
tar -tzf /backups/nginx_backup_YYYY-MM-DD.tar.gz All backup logs are stored in:
/var/log/apache_backup.log
/var/log/nginx_backup.log
To check the latest log entries, run:
tail -f /var/log/apache_backup.log
tail -f /var/log/nginx_backup.log✔️ Cron job configurations for Sarah and Mike
✔️ Backup files created in /backups/
✔️ Verification logs confirming successful backups