2

I am running Wheezy Debian. When I try to create a new file in a directory other than my home directory, such as /var/www, I get the following error in vim:

E212: Cannot open file for writing.

I assume this is because I do not have the correct privileges to create files outside of my home directory?

My user account is in the sudoers file with (ALL=(ALL) ALL), and I have administrator access.

I'm aware of tricks such as :w !sudo tee %, however this still results in a readonly file.

What am I missing here?

5

Sorry I am not able to comment yet. Try to run command :sudo -s by this you will login as root. Then, I guess, you can do whatever work you want to.

| improve this answer | |
2

You need to run vim as root.

sudo vim /var/www/file
| improve this answer | |
0

Thanks for the answers. I ended up solving the issue by changing the the folder owner to myself, using chown. This resulted in me not having to use sudo everytime I wanted to create/edit a file.

| improve this answer | |
  • 2
    Please don't do that. There's a reason why those directories are protected. You should use sudo every time you want to create a file, it's not that hard and it's worth it to keep your system secure. – terdon Jul 18 '14 at 7:28

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