Skip to content

Instantly share code, notes, and snippets.

@vdbsh
Created October 22, 2025 19:54
Show Gist options
  • Select an option

  • Save vdbsh/f03dc9ebb3c8b3cfb8784968c377ae80 to your computer and use it in GitHub Desktop.

Select an option

Save vdbsh/f03dc9ebb3c8b3cfb8784968c377ae80 to your computer and use it in GitHub Desktop.
Sprays away the Rust coreutils and sudo‑rs from Ubuntu 25.10+, restoring trusty GNU tools
#!/usr/bin/env bash
#
# wd40.sh – “spray away” the Rust coreutils and sudo‑rs from Ubuntu 25.10+, restoring trusty GNU tools
#
# --------------------------------------------------------------
set -euo pipefail
# ---------- Helper functions ----------
log() { echo -e "\e[1;34m[INFO]\e[0m $*"; }
warn() { echo -e "\e[1;33m[WARN]\e[0m $*" >&2; }
error() { echo -e "\e[1;31m[ERROR]\e[0m $*" >&2; exit 1; }
# ---------- Re‑install the GNU packages ----------
log "Updating package lists…"
apt-get update -qq
log "Re‑installing GNU coreutils…"
apt-get install --reinstall -y coreutils
log "Re‑installing GNU sudo…"
apt-get install --reinstall -y sudo
# ---------- Purge the Rust packages ----------
RUST_COREUTILS_PKG="rust-coreutils"
RUST_SUDO_PKG="sudo-rs"
purge_if_installed() {
local pkg=$1
if dpkg -s "$pkg" >/dev/null 2>&1; then
log "Purging $pkg …"
apt-get purge -y "$pkg"
else
warn "Package $pkg not installed – nothing to purge."
fi
}
purge_if_installed "$RUST_COREUTILS_PKG"
purge_if_installed "$RUST_SUDO_PKG"
# ---------- (Optional) Create APT pins to block future reinstalls ----------
create_pin() {
local pkg=$1
local pinfile="/etc/apt/preferences.d/no-${pkg}"
if [[ -f "$pinfile" ]]; then
warn "Pin file $pinfile already exists – leaving it unchanged."
return
fi
cat <<EOF | tee "$pinfile" >/dev/null
Package: $pkg
Pin: release *
Pin-Priority: -1
EOF
log "Created APT pin for $pkg (priority -1)."
}
log "Creating APT pins to prevent accidental reinstall of Rust packages…"
create_pin "$RUST_COREUTILS_PKG"
create_pin "$RUST_SUDO_PKG"
# ---------- Verify the revert ----------
log "Verifying GNU coreutils…"
if ls --version 2>/dev/null | grep -q "GNU coreutils"; then
log "✅ ls reports GNU coreutils."
else
warn "ls does NOT report GNU coreutils – please check manually."
fi
log "Verifying GNU sudo…"
if sudo --version 2>/dev/null | grep -q "Sudo version"; then
log "✅ sudo reports the GNU version."
else
warn "sudo does NOT report the GNU version – please check manually."
fi
log "All done! Your system now runs the classic GNU coreutils and sudo."
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment