Week 3 Challenge 1: User Account Management
Introduction:
This challenge involves creating a robust Bash script to manage user accounts on a Linux system. The script allows administrators to perform essential user account tasks such as creation, deletion, password resets, and more, all from the command line.
It is designed in a way that if we run ./user_management.sh cmd firstly the prompt will appear asking
Enter -c or --create to Create to Create a New User
Enter -d or --delete to delete a user
Enter -r to --reset to reset the password of an existing user account
Enter -r to --reset to reset the password of an existing user account
Enter -h or --help that displays usage information and the available command-line options for the script
Challenge 2 : Automated Backup & Recovery Script with Rotation
code:
#!/bin/bash
<< comment
This is a shell script solution for Task-2 for Week 3 challenge
comment
# Define destination and backup directory
dest=$1
backup_dir="/home/ubuntu/90DaysOfDevOps/2025/shell_scripting/backups"
# Ensure the backup directory exists
mkdir -p "$backup_dir"
# Generate backup filename
file_nm="backup_$(date +%Y-%m-%d_%H-%M-%S).zip"
# Create the backup zip
sudo zip -r "$backup_dir/$file_nm" "$dest"
# Change to backup directory
cd "$backup_dir" || exit
# Initialize counter
count=0
# Loop through sorted files and delete older backups
for file in $(ls -t); do
count=$((count + 1))
if [[ $count -gt 3 ]]; then
rm -rf "$file"
fi
done