This topic should interest all Linux administrators as it is them who do the changes. Be it a home user, or a corporate admin. Without a doubt, no one wants to cripple their system just because power went down, or an
ssh session was interrupted by a bad connection, etcetera.
What's more, I enable you by using this script to edit files comfortably even from a GUI editor of your choice.
POSIX shells compatibility
This script enables you to edit text files on Linux as
root safely through
Internal workings are that
sudoedit copies the file into a temporary file, and overwrites the original file if, and only if, that file has successfuly been changed (saved) and the text editor properly exited.
Visit the latest release download page. Directly download the file named
sudoedit-enhanced in that release. Note, that there is no need to adjust name or permissions, but you are free to do so if you wish.
Once downloaded, place the script somewhere it can stay for good.
Please, customize the editors lists to your preference before actually using this script, by default there are these specified at the beginning of the script:
sudoedit__cli_editor_list='nano vi' sudoedit__gui_editor_list='gedit emacs xed subl code'
You don't have to explicitly remove those not present in your system, as the script checks on existence of the editors upon every call (more precisely upon every sourcing to your shell's environment).
shell's environmentIntegration into your
There are multiple ways to source my script to your
bash, of course.
My personal recommendation is to create (if not yet existing) the
~/.bash_aliases file and source my script from there using the dot (.):
Afterward, you need to make sure that these (or similar) lines are present and not commented out in your
if [ -f ~/.bash_aliases ]; then . ~/.bash_aliases fi
On every machine, there will always be different number of
As said before, the script checks on existence of each editor. This is true also for
aliases begin with
su + name of the editor.
Examples of an actual use
Disclaimer: There is absolutely no affiliation with Nano editor team, but I personaly like this command-line editor.
Disclaimer: There is absolutely no affiliation with Sublime-Text editor team, but I personaly like this graphical-interface editor.
Reporting bugs and suggestions
Please open a new issue ticket.