sudoedit
Safely edit files with elevated privileges
TLDR
Edit file as root
SYNOPSIS
sudoedit [-u user] [options] files
DESCRIPTION
sudoedit safely edits files with elevated privileges. It's equivalent to sudo -e.
File is copied to temp location. User edits with their own editor.
After editing, changes copy back. Original file replaced atomically.
User's environment is preserved. Editor runs as the user, not root.
Safer than running editor as root. Limits privilege escalation risks.
PARAMETERS
-u, --user USER
Edit as user.-g, --group GROUP
Edit with group.-H
Set HOME.-n, --non-interactive
Non-interactive mode.
ENVIRONMENT
SUDO_EDITOR - Preferred editor
VISUAL - Visual editor
EDITOR - Default editor
CAVEATS
Editor plugins run as user. Some editors may not work. Temp files briefly exist.
HISTORY
sudoedit is part of sudo, providing secure file editing. It prevents running arbitrary code with root privileges through editor extensions.
