Save an edited file in nano, but no permissions
I edited a file in /etc/ that I want to save, but forgot to open it using sudo. I remember there was a command to save such a file in vi, and want to know if there is any such way to do it in nano?
Thanks.
sudo text-editor nano
add a comment |
I edited a file in /etc/ that I want to save, but forgot to open it using sudo. I remember there was a command to save such a file in vi, and want to know if there is any such way to do it in nano?
Thanks.
sudo text-editor nano
The changes are extensive. I suppose I can open a new terminal, hen-pick the changes and copy paste them. Or just copy-paste the whole thing. But I was wondering if there was a "geeky" way of doing it.
– theTuxRacer
Nov 30 '10 at 5:19
add a comment |
I edited a file in /etc/ that I want to save, but forgot to open it using sudo. I remember there was a command to save such a file in vi, and want to know if there is any such way to do it in nano?
Thanks.
sudo text-editor nano
I edited a file in /etc/ that I want to save, but forgot to open it using sudo. I remember there was a command to save such a file in vi, and want to know if there is any such way to do it in nano?
Thanks.
sudo text-editor nano
sudo text-editor nano
asked Nov 30 '10 at 5:07
theTuxRacertheTuxRacer
7,497156187
7,497156187
The changes are extensive. I suppose I can open a new terminal, hen-pick the changes and copy paste them. Or just copy-paste the whole thing. But I was wondering if there was a "geeky" way of doing it.
– theTuxRacer
Nov 30 '10 at 5:19
add a comment |
The changes are extensive. I suppose I can open a new terminal, hen-pick the changes and copy paste them. Or just copy-paste the whole thing. But I was wondering if there was a "geeky" way of doing it.
– theTuxRacer
Nov 30 '10 at 5:19
The changes are extensive. I suppose I can open a new terminal, hen-pick the changes and copy paste them. Or just copy-paste the whole thing. But I was wondering if there was a "geeky" way of doing it.
– theTuxRacer
Nov 30 '10 at 5:19
The changes are extensive. I suppose I can open a new terminal, hen-pick the changes and copy paste them. Or just copy-paste the whole thing. But I was wondering if there was a "geeky" way of doing it.
– theTuxRacer
Nov 30 '10 at 5:19
add a comment |
3 Answers
3
active
oldest
votes
Yes you could save it temporarily to your home directory. Press Ctrl+O to change the path to your home directory or in /tmp and then press Enter to save it. Then you can sudo mv
it.
Press CTRL+O will show you the path. Change that to your home directory or /tmp. For example File Name to Write: /tmp/filename and press Enter.
3
You need tosudo cp </full/temp/name> </full/original/name>
andrm </full/temp/name>
to maintain permissions on the original file.sudo mv
will destroy them, which is not what you want, especially if it had executable permissions.
– Martin Thornton
Jul 11 '15 at 14:34
add a comment |
Just open a new tab in terminal, use chmod to change permissions of the file to 777, save the file in nano, then change the permissions back to what they were, probably 644. An alternative is to change owner using chown to yourself, save the file, and change ownership back to root.
1
Coupled with Ctrl + z andfg
this is hands down the fastest way to do it.
– Jervelund
Dec 13 '14 at 11:11
I find this way easier and faster than the accepted answer (Y)
– Sudip Bhandari
Nov 2 '16 at 14:17
add a comment |
Try ctrl+o and choose to save the file to your home folder.
Then do sudo mv /home/username/file /etc/
yeah, i guess I could do that. thanks. but ill still hold on accepting it, to see if there is really a way.
– theTuxRacer
Nov 30 '10 at 5:35
add a comment |
Your Answer
StackExchange.ready(function() {
var channelOptions = {
tags: "".split(" "),
id: "89"
};
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: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
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%2faskubuntu.com%2fquestions%2f15447%2fsave-an-edited-file-in-nano-but-no-permissions%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
Yes you could save it temporarily to your home directory. Press Ctrl+O to change the path to your home directory or in /tmp and then press Enter to save it. Then you can sudo mv
it.
Press CTRL+O will show you the path. Change that to your home directory or /tmp. For example File Name to Write: /tmp/filename and press Enter.
3
You need tosudo cp </full/temp/name> </full/original/name>
andrm </full/temp/name>
to maintain permissions on the original file.sudo mv
will destroy them, which is not what you want, especially if it had executable permissions.
– Martin Thornton
Jul 11 '15 at 14:34
add a comment |
Yes you could save it temporarily to your home directory. Press Ctrl+O to change the path to your home directory or in /tmp and then press Enter to save it. Then you can sudo mv
it.
Press CTRL+O will show you the path. Change that to your home directory or /tmp. For example File Name to Write: /tmp/filename and press Enter.
3
You need tosudo cp </full/temp/name> </full/original/name>
andrm </full/temp/name>
to maintain permissions on the original file.sudo mv
will destroy them, which is not what you want, especially if it had executable permissions.
– Martin Thornton
Jul 11 '15 at 14:34
add a comment |
Yes you could save it temporarily to your home directory. Press Ctrl+O to change the path to your home directory or in /tmp and then press Enter to save it. Then you can sudo mv
it.
Press CTRL+O will show you the path. Change that to your home directory or /tmp. For example File Name to Write: /tmp/filename and press Enter.
Yes you could save it temporarily to your home directory. Press Ctrl+O to change the path to your home directory or in /tmp and then press Enter to save it. Then you can sudo mv
it.
Press CTRL+O will show you the path. Change that to your home directory or /tmp. For example File Name to Write: /tmp/filename and press Enter.
edited Feb 2 at 19:47
wjandrea
9,46042664
9,46042664
answered Nov 30 '10 at 5:23
karthick87karthick87
49.9k54167218
49.9k54167218
3
You need tosudo cp </full/temp/name> </full/original/name>
andrm </full/temp/name>
to maintain permissions on the original file.sudo mv
will destroy them, which is not what you want, especially if it had executable permissions.
– Martin Thornton
Jul 11 '15 at 14:34
add a comment |
3
You need tosudo cp </full/temp/name> </full/original/name>
andrm </full/temp/name>
to maintain permissions on the original file.sudo mv
will destroy them, which is not what you want, especially if it had executable permissions.
– Martin Thornton
Jul 11 '15 at 14:34
3
3
You need to
sudo cp </full/temp/name> </full/original/name>
and rm </full/temp/name>
to maintain permissions on the original file. sudo mv
will destroy them, which is not what you want, especially if it had executable permissions.– Martin Thornton
Jul 11 '15 at 14:34
You need to
sudo cp </full/temp/name> </full/original/name>
and rm </full/temp/name>
to maintain permissions on the original file. sudo mv
will destroy them, which is not what you want, especially if it had executable permissions.– Martin Thornton
Jul 11 '15 at 14:34
add a comment |
Just open a new tab in terminal, use chmod to change permissions of the file to 777, save the file in nano, then change the permissions back to what they were, probably 644. An alternative is to change owner using chown to yourself, save the file, and change ownership back to root.
1
Coupled with Ctrl + z andfg
this is hands down the fastest way to do it.
– Jervelund
Dec 13 '14 at 11:11
I find this way easier and faster than the accepted answer (Y)
– Sudip Bhandari
Nov 2 '16 at 14:17
add a comment |
Just open a new tab in terminal, use chmod to change permissions of the file to 777, save the file in nano, then change the permissions back to what they were, probably 644. An alternative is to change owner using chown to yourself, save the file, and change ownership back to root.
1
Coupled with Ctrl + z andfg
this is hands down the fastest way to do it.
– Jervelund
Dec 13 '14 at 11:11
I find this way easier and faster than the accepted answer (Y)
– Sudip Bhandari
Nov 2 '16 at 14:17
add a comment |
Just open a new tab in terminal, use chmod to change permissions of the file to 777, save the file in nano, then change the permissions back to what they were, probably 644. An alternative is to change owner using chown to yourself, save the file, and change ownership back to root.
Just open a new tab in terminal, use chmod to change permissions of the file to 777, save the file in nano, then change the permissions back to what they were, probably 644. An alternative is to change owner using chown to yourself, save the file, and change ownership back to root.
answered Dec 1 '10 at 3:10
charlie-tcacharlie-tca
1,119915
1,119915
1
Coupled with Ctrl + z andfg
this is hands down the fastest way to do it.
– Jervelund
Dec 13 '14 at 11:11
I find this way easier and faster than the accepted answer (Y)
– Sudip Bhandari
Nov 2 '16 at 14:17
add a comment |
1
Coupled with Ctrl + z andfg
this is hands down the fastest way to do it.
– Jervelund
Dec 13 '14 at 11:11
I find this way easier and faster than the accepted answer (Y)
– Sudip Bhandari
Nov 2 '16 at 14:17
1
1
Coupled with Ctrl + z and
fg
this is hands down the fastest way to do it.– Jervelund
Dec 13 '14 at 11:11
Coupled with Ctrl + z and
fg
this is hands down the fastest way to do it.– Jervelund
Dec 13 '14 at 11:11
I find this way easier and faster than the accepted answer (Y)
– Sudip Bhandari
Nov 2 '16 at 14:17
I find this way easier and faster than the accepted answer (Y)
– Sudip Bhandari
Nov 2 '16 at 14:17
add a comment |
Try ctrl+o and choose to save the file to your home folder.
Then do sudo mv /home/username/file /etc/
yeah, i guess I could do that. thanks. but ill still hold on accepting it, to see if there is really a way.
– theTuxRacer
Nov 30 '10 at 5:35
add a comment |
Try ctrl+o and choose to save the file to your home folder.
Then do sudo mv /home/username/file /etc/
yeah, i guess I could do that. thanks. but ill still hold on accepting it, to see if there is really a way.
– theTuxRacer
Nov 30 '10 at 5:35
add a comment |
Try ctrl+o and choose to save the file to your home folder.
Then do sudo mv /home/username/file /etc/
Try ctrl+o and choose to save the file to your home folder.
Then do sudo mv /home/username/file /etc/
answered Nov 30 '10 at 5:25
RolandiXor♦RolandiXor
44.8k26140231
44.8k26140231
yeah, i guess I could do that. thanks. but ill still hold on accepting it, to see if there is really a way.
– theTuxRacer
Nov 30 '10 at 5:35
add a comment |
yeah, i guess I could do that. thanks. but ill still hold on accepting it, to see if there is really a way.
– theTuxRacer
Nov 30 '10 at 5:35
yeah, i guess I could do that. thanks. but ill still hold on accepting it, to see if there is really a way.
– theTuxRacer
Nov 30 '10 at 5:35
yeah, i guess I could do that. thanks. but ill still hold on accepting it, to see if there is really a way.
– theTuxRacer
Nov 30 '10 at 5:35
add a comment |
Thanks for contributing an answer to Ask Ubuntu!
- 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%2faskubuntu.com%2fquestions%2f15447%2fsave-an-edited-file-in-nano-but-no-permissions%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
The changes are extensive. I suppose I can open a new terminal, hen-pick the changes and copy paste them. Or just copy-paste the whole thing. But I was wondering if there was a "geeky" way of doing it.
– theTuxRacer
Nov 30 '10 at 5:19