Take the 2-minute tour ×
Ask Ubuntu is a question and answer site for Ubuntu users and developers. It's 100% free, no registration required.

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.

share|improve this question
    
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 comment

3 Answers

up vote 8 down vote accepted

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.

alt text 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.

share|improve this answer
add comment

Try ctrl+o and choose to save the file to your home folder.

Then do sudo mv /home/username/file /etc/

share|improve this answer
    
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 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.

share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.