Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Binary file added backups/backup_20260402_151406.tar.gz
Binary file not shown.
Binary file added backups/backup_20260402_152227.tar.gz
Binary file not shown.
78 changes: 78 additions & 0 deletions logs/app.log
Original file line number Diff line number Diff line change
@@ -0,0 +1,78 @@
total 24K
-rw-r--r-- 1 the_godbeing the_godbeing 612 Apr 2 15:13 backup.sh
-rw-r--r-- 1 the_godbeing the_godbeing 925 Apr 2 14:55 file_manager.sh
-rw-r--r-- 1 the_godbeing the_godbeing 385 Apr 2 15:17 process_monitor.sh
-rw-r--r-- 1 the_godbeing the_godbeing 597 Apr 2 15:20 run_all.sh
-rw-r--r-- 1 the_godbeing the_godbeing 839 Apr 2 14:31 system_check.sh
-rw-r--r-- 1 the_godbeing the_godbeing 671 Apr 2 11:19 user_info.sh
===== SYSTEM REPORT =====
---------- Disk Usage ----------
Filesystem Size Used Avail Use% Mounted on
none 3.9G 0 3.9G 0% /usr/lib/modules/6.6.87.2-microsoft-standard-WSL2
none 3.9G 4.0K 3.9G 1% /mnt/wsl
drivers 238G 101G 137G 43% /usr/lib/wsl/drivers
/dev/sdd 1007G 1.6G 955G 1% /
none 3.9G 112K 3.9G 1% /mnt/wslg
none 3.9G 0 3.9G 0% /usr/lib/wsl/lib
rootfs 3.9G 2.7M 3.9G 1% /init
none 3.9G 488K 3.9G 1% /run
none 3.9G 0 3.9G 0% /run/lock
none 3.9G 0 3.9G 0% /run/shm
none 3.9G 76K 3.9G 1% /mnt/wslg/versions.txt
none 3.9G 76K 3.9G 1% /mnt/wslg/doc
C:\ 238G 101G 137G 43% /mnt/c
tmpfs 789M 8.0K 789M 1% /run/user/1000
---------- Memory Usage ----------
total used free shared buff/cache available
Mem: 7881 318 7401 3 161 7405
Swap: 2048 0 2048
---------- CPU Load ----------
15:22:27 up 4:50, 1 user, load average: 0.00, 0.00, 0.00
----- Total running processes: 35
---------- Top 5 memory-consuming processes ----------
USER PID %CPU %MEM VSZ RSS TTY STAT START TIME COMMAND
root 218 0.0 0.2 107164 21632 ? Ssl 10:33 0:00 /usr/bin/python3 /usr/share/unattended-upgrades/unattended-upgrade-shutdown --wait-for-signal
root 808 0.0 0.2 293004 19968 ? Ssl 10:36 0:00 /usr/libexec/packagekitd
root 186 0.0 0.2 30136 18560 ? Ss 10:33 0:00 /usr/bin/python3 /usr/bin/networkd-dispatcher --run-startup-triggers
root 63 0.0 0.1 47828 15104 ? S<s 10:33 0:02 /lib/systemd/systemd-journald
systemd+ 95 0.0 0.1 25672 13312 ? Ss 10:33 0:00 /lib/systemd/systemd-resolved
Backup created: ../backups/backup_20260402_152227.tar.gz
Old backups cleaned up
nginx is Stopped. Restarting...
nginx Restarted
ssh is Stopped. Restarting...
ssh Restarted
docker is Stopped. Restarting...
docker Restarted
Hello David from Nigeria! You are an Adult.
===== SYSTEM REPORT =====
---------- Disk Usage ----------
Filesystem Size Used Avail Use% Mounted on
none 3.9G 0 3.9G 0% /usr/lib/modules/6.6.87.2-microsoft-standard-WSL2
none 3.9G 4.0K 3.9G 1% /mnt/wsl
drivers 238G 101G 137G 43% /usr/lib/wsl/drivers
/dev/sdd 1007G 1.6G 955G 1% /
none 3.9G 112K 3.9G 1% /mnt/wslg
none 3.9G 0 3.9G 0% /usr/lib/wsl/lib
rootfs 3.9G 2.7M 3.9G 1% /init
none 3.9G 488K 3.9G 1% /run
none 3.9G 0 3.9G 0% /run/lock
none 3.9G 0 3.9G 0% /run/shm
none 3.9G 76K 3.9G 1% /mnt/wslg/versions.txt
none 3.9G 76K 3.9G 1% /mnt/wslg/doc
C:\ 238G 101G 137G 43% /mnt/c
tmpfs 789M 8.0K 789M 1% /run/user/1000
---------- Memory Usage ----------
total used free shared buff/cache available
Mem: 7881 319 7400 3 161 7404
Swap: 2048 0 2048
---------- CPU Load ----------
15:23:47 up 4:51, 1 user, load average: 0.00, 0.00, 0.00
----- Total running processes: 34
---------- Top 5 memory-consuming processes ----------
USER PID %CPU %MEM VSZ RSS TTY STAT START TIME COMMAND
root 218 0.0 0.2 107164 21632 ? Ssl 10:33 0:00 /usr/bin/python3 /usr/share/unattended-upgrades/unattended-upgrade-shutdown --wait-for-signal
root 808 0.0 0.2 293004 19968 ? Ssl 10:36 0:00 /usr/libexec/packagekitd
root 186 0.0 0.2 30136 18560 ? Ss 10:33 0:00 /usr/bin/python3 /usr/bin/networkd-dispatcher --run-startup-triggers
root 63 0.0 0.1 47828 15104 ? S<s 10:33 0:02 /lib/systemd/systemd-journald
systemd+ 95 0.0 0.1 25672 13312 ? Ss 10:33 0:00 /lib/systemd/systemd-resolved
6 changes: 6 additions & 0 deletions logs/backup.log
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
Error: Directory does not exist
Usage: backup.sh <Source directory>
Backup created: ../backups/backup_20260402_151406.tar.gz
Old backups cleaned up
Backup created: ../backups/backup_20260402_152227.tar.gz
Old backups cleaned up
15 changes: 15 additions & 0 deletions logs/file_manager.log
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
File created: sample.txt
total 12K
-rw-r--r-- 1 the_godbeing the_godbeing 925 Apr 2 14:55 file_manager.sh
-rw-r--r-- 1 the_godbeing the_godbeing 0 Apr 2 14:56 sample.txt
-rw-r--r-- 1 the_godbeing the_godbeing 839 Apr 2 14:31 system_check.sh
-rw-r--r-- 1 the_godbeing the_godbeing 671 Apr 2 11:19 user_info.sh
Renamed sample.txt to sample1.txt
File deleted: sample1.txt
total 24K
-rw-r--r-- 1 the_godbeing the_godbeing 612 Apr 2 15:13 backup.sh
-rw-r--r-- 1 the_godbeing the_godbeing 925 Apr 2 14:55 file_manager.sh
-rw-r--r-- 1 the_godbeing the_godbeing 385 Apr 2 15:17 process_monitor.sh
-rw-r--r-- 1 the_godbeing the_godbeing 597 Apr 2 15:20 run_all.sh
-rw-r--r-- 1 the_godbeing the_godbeing 839 Apr 2 14:31 system_check.sh
-rw-r--r-- 1 the_godbeing the_godbeing 671 Apr 2 11:19 user_info.sh
12 changes: 12 additions & 0 deletions logs/process_monitor.log
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
nginx is Stopped. Restarting...
nginx Restarted
ssh is Stopped. Restarting...
ssh Restarted
docker is Stopped. Restarting...
docker Restarted
nginx is Stopped. Restarting...
nginx Restarted
ssh is Stopped. Restarting...
ssh Restarted
docker is Stopped. Restarting...
docker Restarted
93 changes: 93 additions & 0 deletions logs/system_report_2026.log
Original file line number Diff line number Diff line change
@@ -0,0 +1,93 @@
===== SYSTEM REPORT =====
---------- Disk Usage ----------
Filesystem Size Used Avail Use% Mounted on
none 3.9G 0 3.9G 0% /usr/lib/modules/6.6.87.2-microsoft-standard-WSL2
none 3.9G 4.0K 3.9G 1% /mnt/wsl
drivers 238G 101G 137G 43% /usr/lib/wsl/drivers
/dev/sdd 1007G 1.6G 955G 1% /
none 3.9G 112K 3.9G 1% /mnt/wslg
none 3.9G 0 3.9G 0% /usr/lib/wsl/lib
rootfs 3.9G 2.7M 3.9G 1% /init
none 3.9G 488K 3.9G 1% /run
none 3.9G 0 3.9G 0% /run/lock
none 3.9G 0 3.9G 0% /run/shm
none 3.9G 76K 3.9G 1% /mnt/wslg/versions.txt
none 3.9G 76K 3.9G 1% /mnt/wslg/doc
C:\ 238G 101G 137G 43% /mnt/c
tmpfs 789M 8.0K 789M 1% /run/user/1000
---------- Memory Usage ----------
total used free shared buff/cache available
Mem: 7881 323 7398 3 159 7400
Swap: 2048 0 2048
---------- CPU Load ----------
14:32:08 up 4:01, 1 user, load average: 0.00, 0.00, 0.00
----- Total running processes: 37
---------- Top 5 memory-consuming processes ----------
USER PID %CPU %MEM VSZ RSS TTY STAT START TIME COMMAND
root 218 0.0 0.2 107164 21632 ? Ssl 10:31 0:00 /usr/bin/python3 /usr/share/unattended-upgrades/unattended-upgrade-shutdown --wait-for-signal
root 808 0.0 0.2 293004 19968 ? Ssl 10:35 0:00 /usr/libexec/packagekitd
root 186 0.0 0.2 30136 18560 ? Ss 10:31 0:00 /usr/bin/python3 /usr/bin/networkd-dispatcher --run-startup-triggers
root 63 0.0 0.1 47828 15104 ? S<s 10:31 0:01 /lib/systemd/systemd-journald
systemd+ 95 0.0 0.1 25672 13312 ? Ss 10:31 0:00 /lib/systemd/systemd-resolved
===== SYSTEM REPORT =====
---------- Disk Usage ----------
Filesystem Size Used Avail Use% Mounted on
none 3.9G 0 3.9G 0% /usr/lib/modules/6.6.87.2-microsoft-standard-WSL2
none 3.9G 4.0K 3.9G 1% /mnt/wsl
drivers 238G 101G 137G 43% /usr/lib/wsl/drivers
/dev/sdd 1007G 1.6G 955G 1% /
none 3.9G 112K 3.9G 1% /mnt/wslg
none 3.9G 0 3.9G 0% /usr/lib/wsl/lib
rootfs 3.9G 2.7M 3.9G 1% /init
none 3.9G 488K 3.9G 1% /run
none 3.9G 0 3.9G 0% /run/lock
none 3.9G 0 3.9G 0% /run/shm
none 3.9G 76K 3.9G 1% /mnt/wslg/versions.txt
none 3.9G 76K 3.9G 1% /mnt/wslg/doc
C:\ 238G 101G 137G 43% /mnt/c
tmpfs 789M 8.0K 789M 1% /run/user/1000
---------- Memory Usage ----------
total used free shared buff/cache available
Mem: 7881 318 7401 3 161 7405
Swap: 2048 0 2048
---------- CPU Load ----------
15:22:27 up 4:50, 1 user, load average: 0.00, 0.00, 0.00
----- Total running processes: 35
---------- Top 5 memory-consuming processes ----------
USER PID %CPU %MEM VSZ RSS TTY STAT START TIME COMMAND
root 218 0.0 0.2 107164 21632 ? Ssl 10:33 0:00 /usr/bin/python3 /usr/share/unattended-upgrades/unattended-upgrade-shutdown --wait-for-signal
root 808 0.0 0.2 293004 19968 ? Ssl 10:36 0:00 /usr/libexec/packagekitd
root 186 0.0 0.2 30136 18560 ? Ss 10:33 0:00 /usr/bin/python3 /usr/bin/networkd-dispatcher --run-startup-triggers
root 63 0.0 0.1 47828 15104 ? S<s 10:33 0:02 /lib/systemd/systemd-journald
systemd+ 95 0.0 0.1 25672 13312 ? Ss 10:33 0:00 /lib/systemd/systemd-resolved
===== SYSTEM REPORT =====
---------- Disk Usage ----------
Filesystem Size Used Avail Use% Mounted on
none 3.9G 0 3.9G 0% /usr/lib/modules/6.6.87.2-microsoft-standard-WSL2
none 3.9G 4.0K 3.9G 1% /mnt/wsl
drivers 238G 101G 137G 43% /usr/lib/wsl/drivers
/dev/sdd 1007G 1.6G 955G 1% /
none 3.9G 112K 3.9G 1% /mnt/wslg
none 3.9G 0 3.9G 0% /usr/lib/wsl/lib
rootfs 3.9G 2.7M 3.9G 1% /init
none 3.9G 488K 3.9G 1% /run
none 3.9G 0 3.9G 0% /run/lock
none 3.9G 0 3.9G 0% /run/shm
none 3.9G 76K 3.9G 1% /mnt/wslg/versions.txt
none 3.9G 76K 3.9G 1% /mnt/wslg/doc
C:\ 238G 101G 137G 43% /mnt/c
tmpfs 789M 8.0K 789M 1% /run/user/1000
---------- Memory Usage ----------
total used free shared buff/cache available
Mem: 7881 319 7400 3 161 7404
Swap: 2048 0 2048
---------- CPU Load ----------
15:23:47 up 4:51, 1 user, load average: 0.00, 0.00, 0.00
----- Total running processes: 34
---------- Top 5 memory-consuming processes ----------
USER PID %CPU %MEM VSZ RSS TTY STAT START TIME COMMAND
root 218 0.0 0.2 107164 21632 ? Ssl 10:33 0:00 /usr/bin/python3 /usr/share/unattended-upgrades/unattended-upgrade-shutdown --wait-for-signal
root 808 0.0 0.2 293004 19968 ? Ssl 10:36 0:00 /usr/libexec/packagekitd
root 186 0.0 0.2 30136 18560 ? Ss 10:33 0:00 /usr/bin/python3 /usr/bin/networkd-dispatcher --run-startup-triggers
root 63 0.0 0.1 47828 15104 ? S<s 10:33 0:02 /lib/systemd/systemd-journald
systemd+ 95 0.0 0.1 25672 13312 ? Ss 10:33 0:00 /lib/systemd/systemd-resolved
2 changes: 2 additions & 0 deletions logs/user_info.log
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
Hello David from Nigeria! You are an Adult.
Hello David from Nigeria! You are an Adult.
Binary file added scripts/.backup.sh.swp
Binary file not shown.
23 changes: 23 additions & 0 deletions scripts/backup.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
#!/bin/bash

SOURCE_DIR=$1
BACKUP_DIR="../backups"
LOG_FILE="../logs/backup.log"

if [[ ! -d "$SOURCE_DIR" ]]; then
echo "Error: Directory does not exist" | tee -a "$LOG_FILE"
echo "Usage: $0 <Source directory>" | tee -a "$LOG_FILE"
exit 1
fi

TIMESTAMP=$(date +"%Y%m%d_%H%M%S")
BACKUP_FILE="$BACKUP_DIR/backup_$TIMESTAMP.tar.gz"

tar -czf "$BACKUP_FILE" "$SOURCE_DIR"

echo "Backup created: $BACKUP_FILE" | tee -a "$LOG_FILE"

# Keep only last 5 backups
ls -t $BACKUP_DIR/backup_*.tar.gz | tail -n +6 | xargs -r rm

echo "Old backups cleaned up" | tee -a "$LOG_FILE"
41 changes: 41 additions & 0 deletions scripts/file_manager.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
#!/bin/bash

LOG_FILE="../logs/file_manager.log"
ACTION=$1
FILE=$2

case "$ACTION" in
create)
if [[ -f "$FILE" ]]; then
echo "File already exists!" | tee -a "$LOG_FILE"
else
touch "$FILE"
echo "File created: $FILE" | tee -a "$LOG_FILE"
fi
;;
delete)
if [[ -f "$FILE" ]]; then
rm "$FILE"
echo "File deleted: $FILE" | tee -a "$LOG_FILE"
else
echo "File not found!" | tee -a "$LOG_FILE"
fi
;;

list)
ls -lh | tee -a "$LOG_FILE"
;;

rename)
NEW_NAME=$3
if [[ -f "$FILE" ]]; then
mv "$FILE" "$NEW_NAME"
echo "Renamed $FILE to $NEW_NAME" | tee -a "$LOG_FILE"
else
echo "File not found!" | tee -a "$LOG_FILE"
fi
;;
*)
echo "Usage: $0 {create|delete|list|rename} filename filename?" | tee -a "$LOG_FILE"
;;
esac
14 changes: 14 additions & 0 deletions scripts/process_monitor.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
#!/bin/bash

LOG_FILE="../logs/process_monitor.log"
services=("nginx" "ssh" "docker")

for service in "${services[@]}"; do
if pgrep -x "$service" > /dev/null; then
echo "$service is Running" | tee -a "$LOG_FILE"
else
echo "$service is Stopped. Restarting..." | tee -a "$LOG_FILE"
# Simulate restart
echo "$service Restarted" | tee -a "$LOG_FILE"
fi
done
33 changes: 33 additions & 0 deletions scripts/run_all.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
#!/bin/bash
set -euo pipefail

LOG_FILE="../logs/app.log"

run_all() {
bash file_manager.sh list
bash system_check.sh
bash backup.sh .
bash process_monitor.sh
bash user_info.sh

}

menu() {
echo "1. Run all"
echo "2. System check"
echo "3. Backup"
echo "4. Exit"
}

while true; do
menu
read -p "Choose option: " choice

case $choice in
1) run_all | tee -a "$LOG_FILE" ;;
2) bash system_check.sh | tee -a "$LOG_FILE" ;;
3) bash backup.sh . | tee -a "$LOG_FILE" ;;
4) exit 0 ;;
*) echo "Invalid option" ;;
esac
done
28 changes: 28 additions & 0 deletions scripts/system_check.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
#!/bin/bash

DATE=$(date +"%Y")
LOG_FILE="../logs/system_report_$DATE.log"

echo "===== SYSTEM REPORT =====" | tee -a "$LOG_FILE"

echo "---------- Disk Usage ----------" | tee -a "$LOG_FILE"
df -h | tee -a "$LOG_FILE"

echo "---------- Memory Usage ----------" | tee -a "$LOG_FILE"
free -m | tee -a "$LOG_FILE"

echo "---------- CPU Load ----------" | tee -a "$LOG_FILE"
uptime | tee -a "$LOG_FILE"

# Disk warning
USAGE=$(df / | awk 'NR==2 {print $5}' | sed 's/%//')
if (( USAGE > 80 )); then
echo "WARNING: Disk usage is above 80%" | tee -a "$LOG_FILE"
fi

# Process count
echo "----- Total running processes: $(ps aux | wc -l)" | tee -a "$LOG_FILE"

# Top 5 memory-consuming processes
echo "---------- Top 5 memory-consuming processes ----------" | tee -a "$LOG_FILE"
ps aux --sort=-%mem | head -n 6 | tee -a "$LOG_FILE"
31 changes: 31 additions & 0 deletions scripts/user_info.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
#!/bin/bash

LOG_FILE="../logs/user_info.log"

read -p "Enter your name: " name
read -p "Enter your age: " age
read -p "Enter your country: " country

# Validate inputs
if [[ -z "$name" || -z "$age" || -z "$country" ]]; then
echo "Error: All fields are required" | tee -a "$LOG_FILE"
exit 1
fi

if ! [[ "$age" =~ ^[0-9]+$ ]]; then
echo "Error: Age must be numeric" | tee -a "$LOG_FILE"
exit 1
fi

# Determine age category
if (( age < 18 )); then
category="Minor"
elif (( age <= 65 )); then
category="Adult"
else
category="Senior"
fi

message="Hello $name from $country! You are an $category."

echo "$message" | tee -a "$LOG_FILE"