Skip to content

Instantly share code, notes, and snippets.

@demonixis
Created September 12, 2025 14:33
Show Gist options
  • Save demonixis/65972b29ffe10604cfe230e3993e5009 to your computer and use it in GitHub Desktop.
Save demonixis/65972b29ffe10604cfe230e3993e5009 to your computer and use it in GitHub Desktop.
A script that dumps startup services, current services, disk storage, etc.. Use the report with a LLM to help you optimize you distro
#!/usr/bin/env bash
# == Robust system snapshot for Fedora 42 ==
# - No 'set -e'; never aborts on single failure
# - Uses timeout to avoid hanging commands
# - Falls back if sudo not available
OUT="fedora_diag_$(hostname)_$(date +%Y%m%d_%H%M%S).txt"
TEE="tee -a \"$OUT\""
TIMEOUT(){ command -v timeout >/dev/null && timeout -k 3 8 "$@" || "$@"; }
SUDO(){ if command -v sudo >/dev/null; then sudo "$@"; else "$@"; fi; }
section () {
echo -e "\n==================== $1 ====================\n" | eval $TEE
}
exec > >(tee -a "$OUT") 2>&1
section "META"
echo "Date: $(date -Is)"
echo "Host: $(hostname 2>/dev/null || echo N/A)"
echo "Uptime: $(uptime -p 2>/dev/null || echo N/A)"
echo "Kernel: $(uname -r)"
echo "OS: $(grep -E '^PRETTY_NAME=' /etc/os-release | cut -d= -f2- | tr -d '\"')"
echo "Shell: $SHELL"
echo "User: $USER (uid: $(id -u))"
echo "Path: $PATH"
section "SESSION / DESKTOP"
TIMEOUT loginctl 2>/dev/null || true
CUR_SES="$(loginctl --no-legend 2>/dev/null | awk -v u="$USER" '$3==u {print $1; exit}')"
echo "Detected session id: ${CUR_SES:-N/A}"
if [ -n "${CUR_SES:-}" ]; then
TIMEOUT loginctl show-session "$CUR_SES" -a 2>/dev/null | egrep -i 'Type=|Desktop=|Name=|Display=' || true
fi
echo "XDG_CURRENT_DESKTOP=${XDG_CURRENT_DESKTOP:-}"
echo "DESKTOP_SESSION=${DESKTOP_SESSION:-}"
echo "XDG_SESSION_TYPE=${XDG_SESSION_TYPE:-}"
section "CPU / MEM / SWAP"
(lscpu || true)
echo
(free -h || true)
echo
(swapon --show || true)
section "STOCKAGE"
(lsblk -o NAME,FSTYPE,SIZE,TYPE,MOUNTPOINTS 2>/dev/null || true)
echo
(df -Th 2>/dev/null | sort -k6,6 || true)
echo
echo "(Top dossiers >1G sous / — peut être long, limité à 20 lignes)"
TIMEOUT SUDO du -xh / --threshold=1G 2>/dev/null | sort -h | tail -n 20 || true
section "RÉSEAU (ports à l’écoute)"
(TIMEOUT ss -tulpn 2>/dev/null || TIMEOUT SUDO ss -tulpn 2>/dev/null || true)
section "SERVICES ACTIFS (systemd)"
(TIMEOUT systemctl --no-pager --type=service --state=running || true)
section "SERVICES ENABLED AU DÉMARRAGE (system)"
(TIMEOUT systemctl --no-pager list-unit-files --type=service 2>/dev/null | awk '$2=="enabled" {print}' || true)
section "SERVICES ENABLED AU DÉMARRAGE (user)"
(TIMEOUT systemctl --user --no-pager list-unit-files --type=service 2>/dev/null | awk '$2=="enabled" {print}' || true)
section "TIMERS systemd"
(TIMEOUT systemctl --no-pager list-timers --all 2>/dev/null || true)
section "BOOT ANALYZE"
(TIMEOUT systemd-analyze time 2>/dev/null || true)
(TIMEOUT systemd-analyze blame 2>/dev/null | head -n 100 || true)
(TIMEOUT systemd-analyze critical-chain 2>/dev/null || true)
section "UNITÉS EN ÉCHEC"
(TIMEOUT systemctl --failed --no-pager 2>/dev/null || true)
section "JOURNAL ERREURS RÉCENTES (niv >= err)"
(TIMEOUT SUDO journalctl -p 3 -xb --no-pager -n 200 2>/dev/null || true)
section "PROCESSUS — TOP (batch)"
(TIMEOUT top -b -n 1 2>/dev/null | head -n 60 || true)
section "PROCESSUS — TOP RAM"
(ps -eo pid,ppid,%mem,%cpu,cmd --sort=-%mem 2>/dev/null | head -n 50 || true)
section "PROCESSUS — TOP CPU"
(ps -eo pid,ppid,%cpu,%mem,cmd --sort=-%cpu 2>/dev/null | head -n 50 || true)
section "ARBRE DE PROCESSUS (pstree)"
(TIMEOUT pstree -a -p -l 2>/dev/null || true)
section "PORTAILS XDG"
(rpm -qa | grep -E '^xdg-desktop-portal' || true)
echo
echo "Processus portails:"
(ps aux | grep -E 'xdg-desktop-portal' | grep -v grep || true)
section "AUTOSTARTS — USER (~/.config/autostart)"
if compgen -G "$HOME/.config/autostart/*.desktop" > /dev/null; then
for f in "$HOME"/.config/autostart/*.desktop; do
echo "--- $(basename "$f") ---"
grep -E '^(Name=|Exec=|OnlyShowIn=|X-GNOME-|X-KDE-)' "$f" || true
done
else
echo "(aucun fichier .desktop dans ~/.config/autostart)"
fi
section "AUTOSTARTS — SYSTÈME (/etc/xdg/autostart)"
if compgen -G "/etc/xdg/autostart/*.desktop" > /dev/null; then
for f in /etc/xdg/autostart/*.desktop; do
echo "--- $(basename "$f") ---"
grep -E '^(Name=|Exec=|OnlyShowIn=|X-GNOME-|X-KDE-)' "$f" || true
done
else
echo "(aucun fichier .desktop dans /etc/xdg/autostart)"
fi
section "FLATPAKS"
(flatpak list --app 2>/dev/null || echo "(flatpak non installé ou aucune app)")
section "CONTAINERS (Docker/Podman)"
(docker ps --format "table {{.ID}}\t{{.Image}}\t{{.Names}}\t{{.Status}}" 2>/dev/null || true)
(podman ps --format "table {{.ID}}\t{{.Image}}\t{{.Names}}\t{{.Status}}" 2>/dev/null || true)
section "CRONS"
echo "Crontab user:"
(crontab -l 2>/dev/null || echo "(pas de crontab user)")
echo
echo "Crons système:"
(ls -la /etc/cron.* 2>/dev/null || true)
section "ENVIRONNEMENT GTK/QT"
echo "GTK_THEME=${GTK_THEME:-}"
echo "QT_QPA_PLATFORMTHEME=${QT_QPA_PLATFORMTHEME:-}"
echo "QT_STYLE_OVERRIDE=${QT_STYLE_OVERRIDE:-}"
section "PAQUETS GNOME/KDE"
echo "Paquets GNOME installés:"
(rpm -qa | grep -E '^gnome(-|$)' | sort || echo "(aucun)")
echo
echo "Portail GNOME:"
(rpm -qa | grep -E '^xdg-desktop-portal-gnome' || echo "(absent)")
echo
echo "Comptage paquets KDE (indicatif):"
(rpm -qa | grep -E '^(plasma-|kde|kf6|kio|kwin)' | wc -l || true) | awk '{print "Total:",$1}'
(rpm -qa | grep -E '^(plasma-|kde|kf6|kio|kwin)' | head -n 50 || true)
section "FIN"
echo "Diagnostic écrit dans: $OUT"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment