Skip to content

Instantly share code, notes, and snippets.

@DeiAsPie
Last active April 7, 2024 17:42
Show Gist options
  • Save DeiAsPie/e8151c735c3584dc80395991dbc4f753 to your computer and use it in GitHub Desktop.
Save DeiAsPie/e8151c735c3584dc80395991dbc4f753 to your computer and use it in GitHub Desktop.
General Recommendations

It is advised not to operate regular text editors as the root user, as these editors can perform functions beyond simple text editing, which could be misused by an attacker. To avoid this risk, consider using the 'sudoedit' command. This command creates a temporary copy of the file, opens the text editor as a non-root user, allows editing of the temporary file, and then replaces the original file as root. This way, the text editor does not run with root privileges.

How to use?

EDITOR=nano sudoedit $path_to_file

  • Not specifying EDITOR, the system will fallback to vi
  • The EDITOR variable can be persistently changed in /etc/environment
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment