I was not able to save the file. How do I save the file? I ran:

vim /etc/apache2/sites-available/laravel.example.com.conf

enter image description here

  • Please don't post screenshots of text. Instead, paste the text directly into your question and use the formatting tools. – terdon Nov 26 '16 at 11:41
  • @muru dunno if this is a permissions issue or a "how can I save a file in vim" issue. I don't see the relevant warning ("Changing readonly file") in the screenshot. – terdon Nov 26 '16 at 11:45
  • @t In that case:, consider askubuntu.com/questions/252760/… as well (about that warning: OP is in insert mode) – muru Nov 26 '16 at 11:47
  • @muru I get the warning in insert mode as well. In fact, it's only in insert mode that I see it (I only get a [readonly] message before I enter insert mode). In any case though, since you'd VTCd on the sudo dupe, I've now closed it as a dupe of both. – terdon Nov 26 '16 at 11:55

You can't edit apache configuration file without root privilege. Use sudo to run vim:

sudo vim /etc/apache2/sites-available/laravel.example.com.conf
| improve this answer | |

vim is a very powerful tool but not exactly easy to use. As a new user, I suggest you instead use nano. Alternatively, you can take the time to learn one of the great editors like vim, emacs etc. If you don't want to take the time to do so, however, stick to nano or gedit.

That said, in order to edit a file in vim, you first need to hit iEsc to leave the INSERT mode, then : to enter commands and wq and then Enter (that's :wq). That will write the file and quit the editor.

Of course, as pointed out by @SuB, you need to do all this (in whatever editor you choose) as root, so sudo vim /path.to/file or sudo nano /path/to/file etc.

| improve this answer | |

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