How to properly edit system files (as root) in GUI (and CLI) in Linux?Cannot open GUI editors in superuser modeNano through Sudoedit = No colorsWhat is your favourite shell script GUI/CLI editor and why?How to create and edit a text file from the bash shellEdit/Remove CLI System NoticeHow do I remotely edit files via ssh?linux + visudo + how to remove sub folder and sub filesEncrypt root file system linuxCan a Unix (Linux) System Launch a GUI from CLI Like (Apple/Microsoft) DOS?What are the GNU programs that I need with Linux if I only edit files?How to edit files in text editor and not terminal when using nano command?CLI (NO GUI) linux distro small memory old pc
LED on same Pin as Toggle Switch, not illuminating
"which" command doesn't work / path of Safari?
What is the white spray-pattern residue inside these Falcon Heavy nozzles?
How can I fix this gap between bookcases I made?
Patience, young "Padovan"
How to type dʒ symbol (IPA) on Mac?
I’m planning on buying a laser printer but concerned about the life cycle of toner in the machine
Why doesn't Newton's third law mean a person bounces back to where they started when they hit the ground?
I probably found a bug with the sudo apt install function
How does one intimidate enemies without having the capacity for violence?
Why can't I see bouncing of a switch on an oscilloscope?
Non-Jewish family in an Orthodox Jewish Wedding
Circuitry of TV splitters
How do you conduct xenoanthropology after first contact?
Simulate Bitwise Cyclic Tag
How to report a triplet of septets in NMR tabulation?
Is there a minimum number of transactions in a block?
How is this relation reflexive?
If Manufacturer spice model and Datasheet give different values which should I use?
Why are 150k or 200k jobs considered good when there are 300k+ births a month?
Can I make popcorn with any corn?
Accidentally leaked the solution to an assignment, what to do now? (I'm the prof)
Japan - Plan around max visa duration
Can an x86 CPU running in real mode be considered to be basically an 8086 CPU?
How to properly edit system files (as root) in GUI (and CLI) in Linux?
Cannot open GUI editors in superuser modeNano through Sudoedit = No colorsWhat is your favourite shell script GUI/CLI editor and why?How to create and edit a text file from the bash shellEdit/Remove CLI System NoticeHow do I remotely edit files via ssh?linux + visudo + how to remove sub folder and sub filesEncrypt root file system linuxCan a Unix (Linux) System Launch a GUI from CLI Like (Apple/Microsoft) DOS?What are the GNU programs that I need with Linux if I only edit files?How to edit files in text editor and not terminal when using nano command?CLI (NO GUI) linux distro small memory old pc
.everyoneloves__top-leaderboard:empty,.everyoneloves__mid-leaderboard:empty,.everyoneloves__bot-mid-leaderboard:empty margin-bottom:0;
System: Linux Mint 18.1 64-bit Cinnamon.
Objective: To define Bash aliases to launch various CLI and GUI text editors while opening a file in root mode from gnome-terminal
emulator.
Progress
For example, the following aliases seem to work as expected:
For CLI, in this example I used Nano (official website):
alias sunano='sudo nano'
For GUI, in this example I used Xed (Wikipedia article):
alias suxed='sudo xed'
They both open a file as root.
Problem
I have an issue with gksudo
in conjunction with sublime-text
:
alias susubl='gksudo /opt/sublime_text/sublime_text'
Sometimes it works. It just does not do anything most of the time.
How do I debug such a thing with inconsistent behavior? It does not output anything. No error message or similar.
Question
gksudo
has been deprecated in Debian and also no longer included in Ubuntu 18.04 Bionic, so let me re-formulate this question to a still valid one:
How to properly edit system files (as root) in GUI (and CLI) in Linux?
Properly in this context I define as safely in case, for instance, a power loss occurs during the file edit, another example could be lost SSH connection, etc.
linux editors sudoedit
add a comment |
System: Linux Mint 18.1 64-bit Cinnamon.
Objective: To define Bash aliases to launch various CLI and GUI text editors while opening a file in root mode from gnome-terminal
emulator.
Progress
For example, the following aliases seem to work as expected:
For CLI, in this example I used Nano (official website):
alias sunano='sudo nano'
For GUI, in this example I used Xed (Wikipedia article):
alias suxed='sudo xed'
They both open a file as root.
Problem
I have an issue with gksudo
in conjunction with sublime-text
:
alias susubl='gksudo /opt/sublime_text/sublime_text'
Sometimes it works. It just does not do anything most of the time.
How do I debug such a thing with inconsistent behavior? It does not output anything. No error message or similar.
Question
gksudo
has been deprecated in Debian and also no longer included in Ubuntu 18.04 Bionic, so let me re-formulate this question to a still valid one:
How to properly edit system files (as root) in GUI (and CLI) in Linux?
Properly in this context I define as safely in case, for instance, a power loss occurs during the file edit, another example could be lost SSH connection, etc.
linux editors sudoedit
add a comment |
System: Linux Mint 18.1 64-bit Cinnamon.
Objective: To define Bash aliases to launch various CLI and GUI text editors while opening a file in root mode from gnome-terminal
emulator.
Progress
For example, the following aliases seem to work as expected:
For CLI, in this example I used Nano (official website):
alias sunano='sudo nano'
For GUI, in this example I used Xed (Wikipedia article):
alias suxed='sudo xed'
They both open a file as root.
Problem
I have an issue with gksudo
in conjunction with sublime-text
:
alias susubl='gksudo /opt/sublime_text/sublime_text'
Sometimes it works. It just does not do anything most of the time.
How do I debug such a thing with inconsistent behavior? It does not output anything. No error message or similar.
Question
gksudo
has been deprecated in Debian and also no longer included in Ubuntu 18.04 Bionic, so let me re-formulate this question to a still valid one:
How to properly edit system files (as root) in GUI (and CLI) in Linux?
Properly in this context I define as safely in case, for instance, a power loss occurs during the file edit, another example could be lost SSH connection, etc.
linux editors sudoedit
System: Linux Mint 18.1 64-bit Cinnamon.
Objective: To define Bash aliases to launch various CLI and GUI text editors while opening a file in root mode from gnome-terminal
emulator.
Progress
For example, the following aliases seem to work as expected:
For CLI, in this example I used Nano (official website):
alias sunano='sudo nano'
For GUI, in this example I used Xed (Wikipedia article):
alias suxed='sudo xed'
They both open a file as root.
Problem
I have an issue with gksudo
in conjunction with sublime-text
:
alias susubl='gksudo /opt/sublime_text/sublime_text'
Sometimes it works. It just does not do anything most of the time.
How do I debug such a thing with inconsistent behavior? It does not output anything. No error message or similar.
Question
gksudo
has been deprecated in Debian and also no longer included in Ubuntu 18.04 Bionic, so let me re-formulate this question to a still valid one:
How to properly edit system files (as root) in GUI (and CLI) in Linux?
Properly in this context I define as safely in case, for instance, a power loss occurs during the file edit, another example could be lost SSH connection, etc.
linux editors sudoedit
linux editors sudoedit
edited 19 hours ago
Vlastimil
asked Apr 5 '17 at 12:22
VlastimilVlastimil
8,5111566146
8,5111566146
add a comment |
add a comment |
3 Answers
3
active
oldest
votes
You shouldn’t run an editor as root unless absolutely necessary, you should set sudoedit
up appropriately. Then you can do
SUDO_EDITOR="/opt/sublime_text/sublime_text -w" sudoedit yourfile
sudoedit
will check you’re allowed to do this, make a copy of the file that you can edit with changing ids, start your editor, and then, when the editor exits, copy the file back if it has been changed.
I’d suggest a function rather than an alias:
function susubl
export SUDO_EDITOR="/opt/sublime_text/sublime_text -w"
sudoedit "$@"
although as Jeff Schaller pointed out, you can use env
to put this in an alias and avoid changing your shell’s environment:
alias susubl='env SUDO_EDITOR="/opt/sublime_text/sublime_text -w" sudoedit'
The -w
option ensures that the Sublime Text invocation waits until the files are closed before returning and letting sudoedit
copy the files back.
add a comment |
Expanding on Stephen Kitt's answer
Find out, on what path your editor is located, e.g.:
$ which nano
/usr/local/bin/nanoAs you can see, I use compiled
nano
, not the packaged version; no matter this can change from system/config to other system/config.The CLI text editors like
vi
ornano
do not seem to have the wait option, so for mynano
andvi
one can write functions like this:# CLI
sunano() env SUDO_EDITOR='/usr/local/bin/nano' sudoedit "$@";
suvi() env SUDO_EDITOR='/usr/bin/vi' sudoedit "$@";The GUI text editors, on the contrary, like Linux Mint's integrated
xed
, free programs like Visual Studio Code (code
), or paid programs like Sublime Text (subl
) all seem to have the wait option, and you need to use it in order to avoid the problem described in my question, you can use something similar to these functions:# GUI
susubl() env SUDO_EDITOR='/opt/sublime_text/sublime_text -w' sudoedit "$@";
sucode() env SUDO_EDITOR='/usr/share/code/bin/code -w' sudoedit "$@";
suxed() env SUDO_EDITOR='/usr/bin/xed -w' sudoedit "$@";
What the -w
(--wait
) option effectively does is, that the editor will wait on the terminal until you close it, thus waiting on close of the editor, enabling further actions to be planned and done on an editor close, in this instance to save the sudoedit
changes. Normally, it would just free the terminal, and you would get a new prompt.
Imagine another useful usage for this:
code -w /home/vlastimil/.bash_aliases; . /home/vlastimil/.bash_aliases
Hopefully, with this example, I make myself clearer.
Generalized and POSIX-ly written ready-to-use function
You should, of course, compile your own list of favorited editors, these are my own, take it only as an example, and populate the list with yours.
# Text editing as root; The proper way through `sudoedit`.
sudoedit_internal()
printf '%sn' "sudoedit_internal(): The path to '$1' editor does not exist on this system." 1>&2
return
editor_wait_option=$2
shift 2
env SUDO_EDITOR="$editor_path $editor_wait_option" sudoedit "$@"
# CLI
suvi() sudoedit_internal vi '' "$@";
sunano() sudoedit_internal nano '' "$@";
# GUI
sucode() sudoedit_internal code -w "$@";
susubl() sudoedit_internal subl -w "$@";
suxed() sudoedit_internal xed -w "$@";
sugedit() sudoedit_internal gedit -w "$@";
add a comment |
Different solution: I never edit system files directly, I make a copy somewhere(*), edit the copy (with my usual editor), and sudo cp
when done.
(*) I have a directory for this, where all files are kept in one place:
- naturally keeps a list of all the file that I have changed
- easy to version
- easy to backup
- easy to transfer to another machine
add a comment |
Your Answer
StackExchange.ready(function()
var channelOptions =
tags: "".split(" "),
id: "106"
;
initTagRenderer("".split(" "), "".split(" "), channelOptions);
StackExchange.using("externalEditor", function()
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled)
StackExchange.using("snippets", function()
createEditor();
);
else
createEditor();
);
function createEditor()
StackExchange.prepareEditor(
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: false,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: null,
bindNavPrevention: true,
postfix: "",
imageUploader:
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
,
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
);
);
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2funix.stackexchange.com%2fquestions%2f356113%2fhow-to-properly-edit-system-files-as-root-in-gui-and-cli-in-linux%23new-answer', 'question_page');
);
Post as a guest
Required, but never shown
3 Answers
3
active
oldest
votes
3 Answers
3
active
oldest
votes
active
oldest
votes
active
oldest
votes
You shouldn’t run an editor as root unless absolutely necessary, you should set sudoedit
up appropriately. Then you can do
SUDO_EDITOR="/opt/sublime_text/sublime_text -w" sudoedit yourfile
sudoedit
will check you’re allowed to do this, make a copy of the file that you can edit with changing ids, start your editor, and then, when the editor exits, copy the file back if it has been changed.
I’d suggest a function rather than an alias:
function susubl
export SUDO_EDITOR="/opt/sublime_text/sublime_text -w"
sudoedit "$@"
although as Jeff Schaller pointed out, you can use env
to put this in an alias and avoid changing your shell’s environment:
alias susubl='env SUDO_EDITOR="/opt/sublime_text/sublime_text -w" sudoedit'
The -w
option ensures that the Sublime Text invocation waits until the files are closed before returning and letting sudoedit
copy the files back.
add a comment |
You shouldn’t run an editor as root unless absolutely necessary, you should set sudoedit
up appropriately. Then you can do
SUDO_EDITOR="/opt/sublime_text/sublime_text -w" sudoedit yourfile
sudoedit
will check you’re allowed to do this, make a copy of the file that you can edit with changing ids, start your editor, and then, when the editor exits, copy the file back if it has been changed.
I’d suggest a function rather than an alias:
function susubl
export SUDO_EDITOR="/opt/sublime_text/sublime_text -w"
sudoedit "$@"
although as Jeff Schaller pointed out, you can use env
to put this in an alias and avoid changing your shell’s environment:
alias susubl='env SUDO_EDITOR="/opt/sublime_text/sublime_text -w" sudoedit'
The -w
option ensures that the Sublime Text invocation waits until the files are closed before returning and letting sudoedit
copy the files back.
add a comment |
You shouldn’t run an editor as root unless absolutely necessary, you should set sudoedit
up appropriately. Then you can do
SUDO_EDITOR="/opt/sublime_text/sublime_text -w" sudoedit yourfile
sudoedit
will check you’re allowed to do this, make a copy of the file that you can edit with changing ids, start your editor, and then, when the editor exits, copy the file back if it has been changed.
I’d suggest a function rather than an alias:
function susubl
export SUDO_EDITOR="/opt/sublime_text/sublime_text -w"
sudoedit "$@"
although as Jeff Schaller pointed out, you can use env
to put this in an alias and avoid changing your shell’s environment:
alias susubl='env SUDO_EDITOR="/opt/sublime_text/sublime_text -w" sudoedit'
The -w
option ensures that the Sublime Text invocation waits until the files are closed before returning and letting sudoedit
copy the files back.
You shouldn’t run an editor as root unless absolutely necessary, you should set sudoedit
up appropriately. Then you can do
SUDO_EDITOR="/opt/sublime_text/sublime_text -w" sudoedit yourfile
sudoedit
will check you’re allowed to do this, make a copy of the file that you can edit with changing ids, start your editor, and then, when the editor exits, copy the file back if it has been changed.
I’d suggest a function rather than an alias:
function susubl
export SUDO_EDITOR="/opt/sublime_text/sublime_text -w"
sudoedit "$@"
although as Jeff Schaller pointed out, you can use env
to put this in an alias and avoid changing your shell’s environment:
alias susubl='env SUDO_EDITOR="/opt/sublime_text/sublime_text -w" sudoedit'
The -w
option ensures that the Sublime Text invocation waits until the files are closed before returning and letting sudoedit
copy the files back.
edited 22 hours ago
answered Apr 5 '17 at 12:46
Stephen KittStephen Kitt
180k25409488
180k25409488
add a comment |
add a comment |
Expanding on Stephen Kitt's answer
Find out, on what path your editor is located, e.g.:
$ which nano
/usr/local/bin/nanoAs you can see, I use compiled
nano
, not the packaged version; no matter this can change from system/config to other system/config.The CLI text editors like
vi
ornano
do not seem to have the wait option, so for mynano
andvi
one can write functions like this:# CLI
sunano() env SUDO_EDITOR='/usr/local/bin/nano' sudoedit "$@";
suvi() env SUDO_EDITOR='/usr/bin/vi' sudoedit "$@";The GUI text editors, on the contrary, like Linux Mint's integrated
xed
, free programs like Visual Studio Code (code
), or paid programs like Sublime Text (subl
) all seem to have the wait option, and you need to use it in order to avoid the problem described in my question, you can use something similar to these functions:# GUI
susubl() env SUDO_EDITOR='/opt/sublime_text/sublime_text -w' sudoedit "$@";
sucode() env SUDO_EDITOR='/usr/share/code/bin/code -w' sudoedit "$@";
suxed() env SUDO_EDITOR='/usr/bin/xed -w' sudoedit "$@";
What the -w
(--wait
) option effectively does is, that the editor will wait on the terminal until you close it, thus waiting on close of the editor, enabling further actions to be planned and done on an editor close, in this instance to save the sudoedit
changes. Normally, it would just free the terminal, and you would get a new prompt.
Imagine another useful usage for this:
code -w /home/vlastimil/.bash_aliases; . /home/vlastimil/.bash_aliases
Hopefully, with this example, I make myself clearer.
Generalized and POSIX-ly written ready-to-use function
You should, of course, compile your own list of favorited editors, these are my own, take it only as an example, and populate the list with yours.
# Text editing as root; The proper way through `sudoedit`.
sudoedit_internal()
printf '%sn' "sudoedit_internal(): The path to '$1' editor does not exist on this system." 1>&2
return
editor_wait_option=$2
shift 2
env SUDO_EDITOR="$editor_path $editor_wait_option" sudoedit "$@"
# CLI
suvi() sudoedit_internal vi '' "$@";
sunano() sudoedit_internal nano '' "$@";
# GUI
sucode() sudoedit_internal code -w "$@";
susubl() sudoedit_internal subl -w "$@";
suxed() sudoedit_internal xed -w "$@";
sugedit() sudoedit_internal gedit -w "$@";
add a comment |
Expanding on Stephen Kitt's answer
Find out, on what path your editor is located, e.g.:
$ which nano
/usr/local/bin/nanoAs you can see, I use compiled
nano
, not the packaged version; no matter this can change from system/config to other system/config.The CLI text editors like
vi
ornano
do not seem to have the wait option, so for mynano
andvi
one can write functions like this:# CLI
sunano() env SUDO_EDITOR='/usr/local/bin/nano' sudoedit "$@";
suvi() env SUDO_EDITOR='/usr/bin/vi' sudoedit "$@";The GUI text editors, on the contrary, like Linux Mint's integrated
xed
, free programs like Visual Studio Code (code
), or paid programs like Sublime Text (subl
) all seem to have the wait option, and you need to use it in order to avoid the problem described in my question, you can use something similar to these functions:# GUI
susubl() env SUDO_EDITOR='/opt/sublime_text/sublime_text -w' sudoedit "$@";
sucode() env SUDO_EDITOR='/usr/share/code/bin/code -w' sudoedit "$@";
suxed() env SUDO_EDITOR='/usr/bin/xed -w' sudoedit "$@";
What the -w
(--wait
) option effectively does is, that the editor will wait on the terminal until you close it, thus waiting on close of the editor, enabling further actions to be planned and done on an editor close, in this instance to save the sudoedit
changes. Normally, it would just free the terminal, and you would get a new prompt.
Imagine another useful usage for this:
code -w /home/vlastimil/.bash_aliases; . /home/vlastimil/.bash_aliases
Hopefully, with this example, I make myself clearer.
Generalized and POSIX-ly written ready-to-use function
You should, of course, compile your own list of favorited editors, these are my own, take it only as an example, and populate the list with yours.
# Text editing as root; The proper way through `sudoedit`.
sudoedit_internal()
printf '%sn' "sudoedit_internal(): The path to '$1' editor does not exist on this system." 1>&2
return
editor_wait_option=$2
shift 2
env SUDO_EDITOR="$editor_path $editor_wait_option" sudoedit "$@"
# CLI
suvi() sudoedit_internal vi '' "$@";
sunano() sudoedit_internal nano '' "$@";
# GUI
sucode() sudoedit_internal code -w "$@";
susubl() sudoedit_internal subl -w "$@";
suxed() sudoedit_internal xed -w "$@";
sugedit() sudoedit_internal gedit -w "$@";
add a comment |
Expanding on Stephen Kitt's answer
Find out, on what path your editor is located, e.g.:
$ which nano
/usr/local/bin/nanoAs you can see, I use compiled
nano
, not the packaged version; no matter this can change from system/config to other system/config.The CLI text editors like
vi
ornano
do not seem to have the wait option, so for mynano
andvi
one can write functions like this:# CLI
sunano() env SUDO_EDITOR='/usr/local/bin/nano' sudoedit "$@";
suvi() env SUDO_EDITOR='/usr/bin/vi' sudoedit "$@";The GUI text editors, on the contrary, like Linux Mint's integrated
xed
, free programs like Visual Studio Code (code
), or paid programs like Sublime Text (subl
) all seem to have the wait option, and you need to use it in order to avoid the problem described in my question, you can use something similar to these functions:# GUI
susubl() env SUDO_EDITOR='/opt/sublime_text/sublime_text -w' sudoedit "$@";
sucode() env SUDO_EDITOR='/usr/share/code/bin/code -w' sudoedit "$@";
suxed() env SUDO_EDITOR='/usr/bin/xed -w' sudoedit "$@";
What the -w
(--wait
) option effectively does is, that the editor will wait on the terminal until you close it, thus waiting on close of the editor, enabling further actions to be planned and done on an editor close, in this instance to save the sudoedit
changes. Normally, it would just free the terminal, and you would get a new prompt.
Imagine another useful usage for this:
code -w /home/vlastimil/.bash_aliases; . /home/vlastimil/.bash_aliases
Hopefully, with this example, I make myself clearer.
Generalized and POSIX-ly written ready-to-use function
You should, of course, compile your own list of favorited editors, these are my own, take it only as an example, and populate the list with yours.
# Text editing as root; The proper way through `sudoedit`.
sudoedit_internal()
printf '%sn' "sudoedit_internal(): The path to '$1' editor does not exist on this system." 1>&2
return
editor_wait_option=$2
shift 2
env SUDO_EDITOR="$editor_path $editor_wait_option" sudoedit "$@"
# CLI
suvi() sudoedit_internal vi '' "$@";
sunano() sudoedit_internal nano '' "$@";
# GUI
sucode() sudoedit_internal code -w "$@";
susubl() sudoedit_internal subl -w "$@";
suxed() sudoedit_internal xed -w "$@";
sugedit() sudoedit_internal gedit -w "$@";
Expanding on Stephen Kitt's answer
Find out, on what path your editor is located, e.g.:
$ which nano
/usr/local/bin/nanoAs you can see, I use compiled
nano
, not the packaged version; no matter this can change from system/config to other system/config.The CLI text editors like
vi
ornano
do not seem to have the wait option, so for mynano
andvi
one can write functions like this:# CLI
sunano() env SUDO_EDITOR='/usr/local/bin/nano' sudoedit "$@";
suvi() env SUDO_EDITOR='/usr/bin/vi' sudoedit "$@";The GUI text editors, on the contrary, like Linux Mint's integrated
xed
, free programs like Visual Studio Code (code
), or paid programs like Sublime Text (subl
) all seem to have the wait option, and you need to use it in order to avoid the problem described in my question, you can use something similar to these functions:# GUI
susubl() env SUDO_EDITOR='/opt/sublime_text/sublime_text -w' sudoedit "$@";
sucode() env SUDO_EDITOR='/usr/share/code/bin/code -w' sudoedit "$@";
suxed() env SUDO_EDITOR='/usr/bin/xed -w' sudoedit "$@";
What the -w
(--wait
) option effectively does is, that the editor will wait on the terminal until you close it, thus waiting on close of the editor, enabling further actions to be planned and done on an editor close, in this instance to save the sudoedit
changes. Normally, it would just free the terminal, and you would get a new prompt.
Imagine another useful usage for this:
code -w /home/vlastimil/.bash_aliases; . /home/vlastimil/.bash_aliases
Hopefully, with this example, I make myself clearer.
Generalized and POSIX-ly written ready-to-use function
You should, of course, compile your own list of favorited editors, these are my own, take it only as an example, and populate the list with yours.
# Text editing as root; The proper way through `sudoedit`.
sudoedit_internal()
printf '%sn' "sudoedit_internal(): The path to '$1' editor does not exist on this system." 1>&2
return
editor_wait_option=$2
shift 2
env SUDO_EDITOR="$editor_path $editor_wait_option" sudoedit "$@"
# CLI
suvi() sudoedit_internal vi '' "$@";
sunano() sudoedit_internal nano '' "$@";
# GUI
sucode() sudoedit_internal code -w "$@";
susubl() sudoedit_internal subl -w "$@";
suxed() sudoedit_internal xed -w "$@";
sugedit() sudoedit_internal gedit -w "$@";
edited 15 hours ago
answered Oct 7 '18 at 12:16
VlastimilVlastimil
8,5111566146
8,5111566146
add a comment |
add a comment |
Different solution: I never edit system files directly, I make a copy somewhere(*), edit the copy (with my usual editor), and sudo cp
when done.
(*) I have a directory for this, where all files are kept in one place:
- naturally keeps a list of all the file that I have changed
- easy to version
- easy to backup
- easy to transfer to another machine
add a comment |
Different solution: I never edit system files directly, I make a copy somewhere(*), edit the copy (with my usual editor), and sudo cp
when done.
(*) I have a directory for this, where all files are kept in one place:
- naturally keeps a list of all the file that I have changed
- easy to version
- easy to backup
- easy to transfer to another machine
add a comment |
Different solution: I never edit system files directly, I make a copy somewhere(*), edit the copy (with my usual editor), and sudo cp
when done.
(*) I have a directory for this, where all files are kept in one place:
- naturally keeps a list of all the file that I have changed
- easy to version
- easy to backup
- easy to transfer to another machine
Different solution: I never edit system files directly, I make a copy somewhere(*), edit the copy (with my usual editor), and sudo cp
when done.
(*) I have a directory for this, where all files are kept in one place:
- naturally keeps a list of all the file that I have changed
- easy to version
- easy to backup
- easy to transfer to another machine
answered 19 hours ago
xenoidxenoid
3,2491826
3,2491826
add a comment |
add a comment |
Thanks for contributing an answer to Unix & Linux Stack Exchange!
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2funix.stackexchange.com%2fquestions%2f356113%2fhow-to-properly-edit-system-files-as-root-in-gui-and-cli-in-linux%23new-answer', 'question_page');
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown