Recent content by marius

  1. M

    System Update Checker Bash Script

    Introduction: This script checks for available system updates on Debian-based systems and displays the summary to the user. Code Snippet: #!/bin/bash # System Update Checker sudo apt update > /dev/null 2>&1 UPDATES=$(apt list --upgradable 2>/dev/null | wc -l) if [ "$UPDATES" -gt 1 ]; then...
  2. M

    Random Password Generator Bash Script

    Introduction: This script generates a random password of a specified length, including letters, numbers, and symbols for enhanced security. Code Snippet: #!/bin/bash # Random Password Generator LENGTH=${1:-12} tr -dc 'A-Za-z0-9_@#%&*' < /dev/urandom | head -c "$LENGTH" echo Instructions: To...
  3. M

    Service Status Checker Bash Script

    Introduction: This script checks the status of a given service and informs if it is active or inactive, ensuring your critical services are running. Code Snippet: #!/bin/bash # Service Status Checker if [ -z "$1" ]; then echo "Usage: $0 <service_name>" exit 1 fi SERVICE=$1 systemctl...
  4. M

    Real-Time Log File Monitor Bash Script

    Introduction: This script allows you to monitor log files in real time, printing new entries as they are appended. Code Snippet: #!/bin/bash # Real-Time Log File Monitor if [ -z "$1" ]; then echo "Usage: $0 <log_file>" exit 1 fi tail -f "$1" Instructions: Make the script executable and...
  5. M

    File Cleanup Utility Bash Script

    Introduction: This script automates cleaning up old files in a directory that have not been accessed for a specified number of days. Code Snippet: #!/bin/bash # File Cleanup Utility if [ -z "$1" ] || [ -z "$2" ]; then echo "Usage: $0 <directory> <days>" exit 1 fi find "$1" -type f -atime...
  6. M

    Network Connectivity Checker Bash Script

    Introduction: This bash script helps you check internet connectivity by pinging a reliable host and reporting the response. Code Snippet: #!/bin/bash # Network Connectivity Checker HOST="8.8.8.8" ping -c 4 $HOST > /dev/null 2>&1 if [ $? -eq 0 ]; then echo "Internet connection is active."...
  7. M

    Directory Tree Visualizer Bash Script

    Introduction: This bash script visualizes the directory structure by listing files and directories in a tree format. Code Snippet: #!/bin/bash # Directory Tree Visualizer if [ -z "$1" ]; then DIR="." else DIR="$1" fi function tree() { for entry in "$1"/*; do if [ -d "$entry" ]; then...
  8. M

    Process Resource Monitor Bash Script

    Introduction: This bash script monitors resource usage (CPU and Memory) of running processes, helping you identify high resource consumers. Code Snippet: #!/bin/bash # Process Resource Monitor ps -eo pid,comm,%cpu,%mem --sort=-%cpu | head Instructions: Make the script executable and run it...
  9. M

    Automated Backup Bash Script

    Introduction: This script automates the process of backing up important files by compressing a directory into a timestamped archive. Code Snippet: #!/bin/bash # Automated Backup Script SOURCE_DIR="$1" BACKUP_DIR="$2" TIMESTAMP=$(date +%Y%m%d_%H%M%S) if [ -z "$SOURCE_DIR" ] || [ -z...
  10. M

    Disk Usage Analyzer Bash Script

    Introduction: This bash script quickly summarizes the disk usage of directories, helping you monitor storage on your system. Code Snippet: #!/bin/bash # Disk Usage Analyzer if [ -z "$1" ]; then echo "Usage: $0 <directory>" exit 1 fi du -sh "$1"/* Instructions: To use the script, first...
  11. M

    System Health Checker Bash Script for Monitoring Resources

    Introduction: This bash script monitors your system's CPU, memory, and disk usage to ensure that your system is performing optimally. It provides a quick snapshot of your resource consumption. #!/bin/bash # Check CPU usage cpu_usage=$(top -bn1 | grep 'Cpu(s)' | \ awk '{print 100 - $8}')...
  12. M

    Network Connectivity Checker Bash Script for Internet Diagnostics

    Introduction: This bash script checks the network connectivity by pinging common websites or IP addresses. It helps diagnose issues with your internet connection quickly. #!/bin/bash # List of hosts to check hosts=("google.com" "amazon.com" "cloudflare.com") for host in "${hosts[@]}" do...
  13. M

    Automated Backup Bash Script for Secure File Backup

    Introduction: This bash script creates backups of specified directories. It compresses the backup into a tar archive and saves it with a timestamp, ensuring your important files are secure. #!/bin/bash # Define backup source and destination SOURCE_DIR="/path/to/important/files"...
  14. M

    Log File Rotator Bash Script to Manage Log Files Efficiently

    Introduction: This bash script rotates log files to prevent them from growing too large over time. It archives the old logs, compresses them, and creates fresh log files for continued logging. #!/bin/bash LOG_DIR="/var/log/myapp" ARCHIVE_DIR="$LOG_DIR/archive" # Create archive directory if...
  15. M

    Automated Server Update Bash Script for Seamless Upgrades

    Introduction: This bash script automates updating your server by fetching and installing the latest package updates. It is especially useful for administrators who need to ensure systems are always up-to-date. #!/bin/bash echo "Starting system update..." # Update package lists and upgrade...
Back
Top