no need to run script as sudo even when doing sudo apt update or anything

PHOTO EMBED

Thu Mar 26 2026 18:56:46 GMT+0000 (Coordinated Universal Time)

Saved by @v1ral_ITS

add this to top of bash script
[ "$UID" -eq 0 ] || exec sudo "$0" "$@"

in python it becomes
if os.geteuid() != 0:
    os.execvp("sudo", ["sudo", sys.executable] + sys.argv)
content_copyCOPY