LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Newbie (https://www.linuxquestions.org/questions/linux-newbie-8/)
-   -   Vi is refusing to save! (https://www.linuxquestions.org/questions/linux-newbie-8/vi-is-refusing-to-save-4175411713/)

Caljoones 06-15-2012 09:56 PM

Vi is refusing to save!
 
Hello everyone!
I have recently installed a command line only version of Ubuntu on a desktop, for the purpose of setting up a Minecraft server. Anyway. I've been trying to edit the interfaces file,for the purpose of giving myself a static IP, using the Vi editor. But, any time I try to save I get this message. "E212: Can't open file for writing." Any help??

nixblog 06-15-2012 10:10 PM

You probably dont have permission to write the changes. You will have to launch vi using sudo,

Code:

sudo vi /etc/network/interfaces
and this should give you the elevated (root) permission to alter that file.

Caljoones 06-15-2012 10:11 PM

Quote:

Originally Posted by nixblog (Post 4704532)
You probably dont have permission to write the changes. You will have to launch vi using sudo,

Code:

sudo vi /etc/network/interfaces
and this should give you the elevated (root) permission to alter that file.

Oh sorry, left that out, thats what I used.

nixblog 06-15-2012 10:21 PM

Have you tried this to save it,

Code:

:w !sudo tee % > /dev/null

ac_kumar 06-16-2012 12:28 AM

can you show ls -l of file

Caljoones 06-16-2012 03:15 PM

Never Mind, I found it out xD

clocker 06-16-2012 04:58 PM

vi has two modes the insert and esc mode to save a file you should be in the esc mode the type.
Quote:

:w filename
like folks have said you should have rwx rights.

Snark1994 06-16-2012 05:21 PM

Quote:

Originally Posted by Caljoones (Post 4705072)
Never Mind, I found it out xD

Well done - please mark the thread as 'SOLVED' and, if applicable, post the solution so people can benefit from your answer. Thanks!

whysoserious 06-16-2012 07:16 PM

Lol at nixblog haha. By the way what did you do if it was not a permissions problem?


All times are GMT -5. The time now is 07:38 PM.