How to properly edit system files (as root) in GUI (and CLI) in Linux? The 2019 Stack Overflow Developer Survey Results Are InCannot 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
Can we generate random numbers using irrational numbers like π and e?
What is the meaning of Triage in Cybersec world?
What do the Banks children have against barley water?
What does ひと匙 mean in this manga and has it been used colloquially?
Worn-tile Scrabble
Is there any way to tell whether the shot is going to hit you or not?
Is a "Democratic" Feudal System Possible?
Geography at the pixel level
Did 3000BC Egyptians use meteoric iron weapons?
How to deal with fear of taking dependencies
Why did Acorn's A3000 have red function keys?
How to support a colleague who finds meetings extremely tiring?
Is "plugging out" electronic devices an American expression?
What is the meaning of the verb "bear" in this context?
What does Linus Torvalds mean when he says that Git "never ever" tracks a file?
Earliest use of the term "Galois extension"?
Why do UK politicians seemingly ignore opinion polls on Brexit?
What did it mean to "align" a radio?
I see my dog run
What could be the right powersource for 15 seconds lifespan disposable giant chainsaw?
One word riddle: Vowel in the middle
How come people say “Would of”?
Right tool to dig six foot holes?
Are there incongruent pythagorean triangles with the same perimeter and same area?
How to properly edit system files (as root) in GUI (and CLI) in Linux?
The 2019 Stack Overflow Developer Survey Results Are InCannot 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 Apr 7 at 8:38
Vlastimil
asked Apr 5 '17 at 12:22
VlastimilVlastimil
8,5781566148
8,5781566148
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
viornanodo not seem to have the wait option, so for mynanoandvione 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_run()
printf '%sn' "sudoedit_run(): The path to '$1' editor does not exist on this system." >&2
return 1
editor_wait_option=$2
shift 2
env SUDO_EDITOR="$editor_path $editor_wait_option" sudoedit "$@"
# shellcheck disable=SC2139
for cli_editor in vi nano
do alias su$cli_editor="sudoedit_run $cli_editor ''"
done
# shellcheck disable=SC2139
for gui_editor in code subl xed gedit
do alias su$gui_editor="sudoedit_run $gui_editor -w"
done
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 Apr 7 at 6:21
answered Apr 5 '17 at 12:46
Stephen KittStephen Kitt
181k25414492
181k25414492
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
viornanodo not seem to have the wait option, so for mynanoandvione 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_run()
printf '%sn' "sudoedit_run(): The path to '$1' editor does not exist on this system." >&2
return 1
editor_wait_option=$2
shift 2
env SUDO_EDITOR="$editor_path $editor_wait_option" sudoedit "$@"
# shellcheck disable=SC2139
for cli_editor in vi nano
do alias su$cli_editor="sudoedit_run $cli_editor ''"
done
# shellcheck disable=SC2139
for gui_editor in code subl xed gedit
do alias su$gui_editor="sudoedit_run $gui_editor -w"
done
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
viornanodo not seem to have the wait option, so for mynanoandvione 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_run()
printf '%sn' "sudoedit_run(): The path to '$1' editor does not exist on this system." >&2
return 1
editor_wait_option=$2
shift 2
env SUDO_EDITOR="$editor_path $editor_wait_option" sudoedit "$@"
# shellcheck disable=SC2139
for cli_editor in vi nano
do alias su$cli_editor="sudoedit_run $cli_editor ''"
done
# shellcheck disable=SC2139
for gui_editor in code subl xed gedit
do alias su$gui_editor="sudoedit_run $gui_editor -w"
done
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
viornanodo not seem to have the wait option, so for mynanoandvione 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_run()
printf '%sn' "sudoedit_run(): The path to '$1' editor does not exist on this system." >&2
return 1
editor_wait_option=$2
shift 2
env SUDO_EDITOR="$editor_path $editor_wait_option" sudoedit "$@"
# shellcheck disable=SC2139
for cli_editor in vi nano
do alias su$cli_editor="sudoedit_run $cli_editor ''"
done
# shellcheck disable=SC2139
for gui_editor in code subl xed gedit
do alias su$gui_editor="sudoedit_run $gui_editor -w"
done
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
viornanodo not seem to have the wait option, so for mynanoandvione 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_run()
printf '%sn' "sudoedit_run(): The path to '$1' editor does not exist on this system." >&2
return 1
editor_wait_option=$2
shift 2
env SUDO_EDITOR="$editor_path $editor_wait_option" sudoedit "$@"
# shellcheck disable=SC2139
for cli_editor in vi nano
do alias su$cli_editor="sudoedit_run $cli_editor ''"
done
# shellcheck disable=SC2139
for gui_editor in code subl xed gedit
do alias su$gui_editor="sudoedit_run $gui_editor -w"
done
edited yesterday
answered Oct 7 '18 at 12:16
VlastimilVlastimil
8,5781566148
8,5781566148
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 Apr 7 at 8:45
xenoidxenoid
3,2641826
3,2641826
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