3

I have a 100 GB of xml doc that I'm migrating to a database in waves.
In vim, I can edit the file, but I'm unable to save changes with :wq, :q or :xx.

I get the error message this file is read only - press ! to override.
Nothing works, so I use the :q! which ignores my changes and exits the vim.

How can i save my changes?

Bonus question

If I don't wait for the entire file to load into memory and press Ctrl + c to view what has been populated, will saving that document only save what was loaded into the memory and delete the rest?

2

The message file is read only - press ! to override means that you don't have permissions to write to the file which you are editing, so the changes you have made can't be written in that file.

Easiest solution is to write the edited file content to the other file with :w file_name, assuming that file_name is a path to a file in which you do have permissions to write.

Other than that you need to find out why you don't have permissions to write to your original file.
You can do that with ls -l file_name.
(I have explained the output of ls -l file_name here.)

Now that you understad a bit more about permissions, you have 3 options:

  1. Use sudo vim file_name to edit the file as the root user.

  2. Give other users write permissions with chmod.

  3. Change the owner of the file with chown.

| improve this answer | |
  • Ahhhh, so that's why you always use sudo to open files. I thought that was just to access them if permission was needed. Perfect. Thank you, sir! – Aaron Brandhagen May 19 '18 at 16:32
  • 2
    @AaronBrandhagen Please don't get the wrong idea, you don't always use sudo, just when you have to. I have updated the answer to give you more options if those make sense in your case. – Iskustvo May 19 '18 at 16:47
  • Even better. Seriously this is a great help, appreciate it. – Aaron Brandhagen May 19 '18 at 17:07
  • 1
    I totaly forgot about that limit, sorry for bothering you than :D I just see a lot of new people forgeting to accept the answer or upvote it, so I thought to mention it. Don't worry about this one, it's not that important :D Best of luck in Unix & Linux! – Iskustvo May 19 '18 at 17:44
  • 2
    Don't even mention it! No worries. I more than appreciate good help that without would otherwise leave me struggling for hours. Giving you credit is the bare minimum I can do - I'll absolutely give you the credit! I'd want the same no doubt. – Aaron Brandhagen May 19 '18 at 18:03

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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