- Rahul (Senior DevOps Engineer, Mentor)
- Sarah (Apache Web Server Developer)
- Mike (Nginx Web Server Developer)
- Vishal Singh (Fresher DevOps Engineer, Contributor)
This project involves configuring a secure and monitored development environment with user management, system monitoring, and automated backups for Apache and Nginx servers. Tasks were performed under the guidance of a senior DevOps engineer to support Sarah and Mike, two new developers at TechCorp.
To set up basic system monitoring to track CPU, memory, disk usage, and identify resource-intensive processes on a development server using Linux (Ubuntu).
- htop – Interactive process viewer
- nmon – System performance monitor
- df – Reports disk space usage
- du – Shows disk usage by directory
- ps – Displays running processes
mkdir devops-assignmentsudo apt update -y
sudo apt install htop nmon -yhtop
nmon- These commands check how much space is being used on your system and in each user’s home directory.
sudo df -h > disk_usage.log
sudo du -sh /home/* >> disk_usage.logdf -h: Displays total, used, and available disk space for all mounted filesystems in a human-readable format (GB, MB).du -sh /home/*: Shows the size of each user's home directory, summarizing space used.>and>>: Used to redirect and append the output todisk_usage.log.
sudo ps aux --sort=-%mem | head -n 6 > top_processes.log
sudo ps aux --sort=-%cpu | head -n 6 >> top_processes.logps aux: Lists all running processes.--sort=-%mem: Sorts by memory usage (descending).--sort=-%cpu: Sorts by CPU usage (descending).head -n 6: Shows top 5 processes plus header.>and>>: Redirects output totop_processes.log.
We implemented process monitoring by:
- Using
ps auxto extract top memory and CPU consuming processes. - Saving results in
top_processes.logfor review. - Using
htopfor interactive, real-time process monitoring.
To maintain a clear audit trail and allow future diagnostics, all monitoring outputs were redirected to log files within the working directory.
- All logs are saved in the
~/devops-assignmentfolder.
/devops-assignment/
├── disk_usage.log
└── top_processes.log
- Enables system admins and developers to review usage trends
- Detects resource bottlenecks
- Supports future capacity planning
These files form the base of a basic reporting structure, essential for any well-managed Linux environment.
To create and manage user accounts for new developers (Sarah and Mike), ensuring each has a secure, isolated working directory. Enforce password policies to meet organizational security standards.
- Sarah
- Mike
sudo adduser sarah
sudo adduser mike- Prompts for passwords and user details.
- Automatically creates
/home/Sarahand/home/mike.
sudo mkdir -p /home/Sarah/workspace
sudo chown Sarah:Sarah /home/Sarah/workspace
sudo chmod 700 /home/Sarah/workspace
sudo mkdir -p /home/mike/workspace
sudo chown mike:mike /home/mike/workspace
sudo chmod 700 /home/mike/workspace📌 Explanation:
mkdir -p: Creates directory if it doesn’t exist.chown: Gives ownership to the user.chmod 700: Only the owner has full access; others have none.
sudo ls -ld /home/sarah/workspace
sudo ls -ld /home/mike/workspacesudo apt install libpam-pwquality -ysudo nano /etc/login.defsUpdate or ensure the following:
PASS_MAX_DAYS 30
PASS_MIN_DAYS 0
PASS_WARN_AGE 7
sudo chage -M 30 sarah
sudo chage -M 30 mike/home/
├── Sarah/
│ └── workspace/
└── Mike/
└── workspace/
Configure automated backups for web server configurations and document root folders for two developers, Sarah (Apache) and Mike (Nginx). The goal is to ensure data safety, integrity, and disaster recovery readiness.
- User -
sarah - Web Server -
Apache - Config Directory -
/etc/apache2/ - Document -
/var/www/html/
- User -
mike - Web Server -
Nginx - Config Directory -
/etc/nginx/ - Document -
/usr/share/nginx/html/
Note: In the assignment mentions
/etc/httpd/, which is valid for CentOS/RedHat. But, this setup uses Ubuntu, the correct Apache config path is/etc/apache2/.
Each user has their own backup folder:
- Sarah:
/home/sarah/backup/ - Mike:
/home/mike/backup/
Inside each folder is a shell script that automates the backup process.
As a Users
mkdir -p ~/backup (Sarah)
mkdir -p ~/backup (Mike)
sudo chown -R sarah:sarah /home/sarah/backup
sudo chown -R mike:mike /home/mike/backup#!/bin/bash
DATE=$(date +%F)
mkdir -p ~/backup/output
tar -czf ~/backup/output/apache_backup_$DATE.tar.gz /etc/apache2/ /var/www/html/
tar -tzf ~/backup/output/apache_backup_$DATE.tar.gz > ~/backup/output/apache_verify_$DATE.logMake it executable:
chmod +x /home/sarah/backup/apache_backup.sh#!/bin/bash
DATE=$(date +%F)
mkdir -p ~/backup/output
tar -czf ~/backup/output/nginx_backup_$DATE.tar.gz /etc/nginx/ /usr/share/nginx/html/
tar -tzf ~/backup/output/nginx_backup_$DATE.tar.gz > ~/backup/output/nginx_verify_$DATE.logMake it executable:
chmod +x /home/mike/backup/nginx_backup.shRun manually to ensure they work:
Sarah:
su - sarah
cd ~/backup
./apache_backup.shMike:
su - mike
cd ~/backup
./nginx_backup.shCheck the generated files:
ls ~/backup/outputOutput for Sarah:
apache_backup_2025-05-13.tar.gz
apache_verify_2025-05-13.log
Output for Mike:
nginx_backup_2025-05-13.tar.gz
nginx_verify_2025-05-13.log
To see if the backup worked:
cat ~/backup/output/apache_verify_2025-05-13.log | head
cat ~/backup/output/nginx_verify_2025-05-13.log | headExample Output:
etc/apache2/
etc/apache2/apache2.conf
var/www/html/index.html
crontab -eAdd:
0 0 * * 2 /home/sarah/backup/apache_backup.sh
crontab -eAdd:
0 0 * * 2 /home/mike/backup/nginx_backup.sh
This schedules the backup to run automatically every Tuesday at 12:00 AM.
crontab -lExpected Output:
0 0 * * 2 /home/sarah/backup/apache_backup.sh
This guide explains the exact steps used to push your local DevOps assignment folder to GitHub, including setting up authentication using a Personal Access Token (PAT).
git initInitializes an empty Git repository inside your current directory.
git remote add origin https://github.com/VishalSingh1996/devops-backup-assignment.gitConnects your local project to your GitHub repository.
git add .Stages all files in the current directory for the commit.
git commit -m "Added logs and user backup scripts"Creates a snapshot of the current project state with a description.
git push -u origin mainThis may fail if the remote repo already has commits (like an auto-created README).
git pullBrings down the remote repository’s existing commits into your local project.
git branch --set-upstream-to=origin/main mainTells Git to track the main branch on GitHub for future pulls/pushes.
git pushThis may fail again if your branch is behind.
git pull --rebase origin mainSafely pulls in changes by replaying your commits on top of the updated remote branch.
git pushNow your code is successfully uploaded to GitHub.
GitHub no longer accepts passwords for pushing to repos. Use a token instead:
- Go to GitHub → Settings → Developer settings
- Click Personal Access Tokens → Tokens (classic)
- Click "Generate new token"
- Check
reposcope - Set expiration and click Generate token
- Copy the token (you won't see it again)
Username: VishalSingh1996
Password: [paste your GitHub token here]
To avoid repeating this:
git config --global credential.helper storeThis saves the token for future pushes.



















