Advertisement
3th1ca14aX0r

Restore Lubuntu script

Feb 28th, 2025
218
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Bash 1.23 KB | Source Code | 0 0
  1. #!/bin/bash
  2.  
  3. # Step 1: Reset dconf settings
  4. echo "Resetting system settings..."
  5. dconf reset -f /
  6.  
  7. # Step 2: Backup and clear user-specific configurations
  8. echo "Backing up and clearing user-specific configurations..."
  9. timestamp=$(date +%Y%m%d_%H%M%S)
  10. mkdir -p ~/backup_configs_$timestamp
  11. mv ~/.config ~/.local ~/.cache ~/backup_configs_$timestamp 2>/dev/null
  12.  
  13. # Step 3: Remove all packages installed after the initial setup
  14. echo "Identifying and removing user-installed packages..."
  15. install_log="/var/log/apt/history.log"
  16. if [ -f "$install_log" ]; then
  17.     grep "Install:" $install_log | awk '{print $4}' | sed 's/,//g' > /tmp/user_installed_packages.txt
  18.     while IFS= read -r package; do
  19.         sudo apt purge -y "$package"
  20.     done < /tmp/user_installed_packages.txt
  21. else
  22.     echo "APT history log not found. Skipping package removal."
  23. fi
  24.  
  25. # Step 4: Clean up unused dependencies and cache
  26. echo "Cleaning up unused dependencies and cache..."
  27. sudo apt autoremove -y
  28. sudo apt autoclean
  29.  
  30. # Step 5: Reinstall Lubuntu desktop environment
  31. echo "Reinstalling Lubuntu desktop environment..."
  32. sudo apt install --reinstall lubuntu-desktop -y
  33.  
  34. # Step 6: Notify completion
  35. echo "System reset complete. Rebooting now..."
  36. sudo reboot
  37.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement