I need to make changes to /etc/apache2/apache2.config

I found instructions that say sudo nano /etc/apache2/apache2.conf

Ok, I got some kind of editor up now. Next step ServerName server_domain_or_IP

Ok, I added the line (with my server name, of course).

Next: Save and Exit. Seems easy enough. just about every Ubuntu help site says the same thing. ^O (writeOut is apparently the save) and ^X

Nope. ^O toggles between "Use of one more line for editing enabled/disabled"

^X toggles "help mode enabled/disabled"


I guess I'll edit this in a GUI-based editor. typetypetypetype Edits made!

File -> Save Of course it's read only.

sudo chmod +w /etc/apache2/apache2.conf

double check... still read only.

research! sudo chmod u+w /etc/apache2/apache2.conf

sudo chmod gu+w /etc/apache2/apache2.conf


All I want to do is edit one file. And I want the help files I read online to do what they say they do.

Why is this so hard? I know I'm a total noob with Linux, but come on! I'm not new to finding help files and following directions.

What am I doing wrong?

  • 5
    You are interprating ^O as "ESC" "O" instead of <CTRL>O. Similar for ^x. Mar 7, 2017 at 22:11
  • @DougSmythies is the answer. If you reproduce what you say when working on nano, the screen shows what The Mick is saying. You should add this as an answer. Mar 7, 2017 at 22:17
  • 2
    Possible duplicate of How to save a file using nano
    – muru
    Mar 8, 2017 at 2:21

2 Answers 2


First revert your chmod: you don't want to make that file world-writable.

sudo chmod 644 /etc/apache2/apache2.conf

"Read only" means you don't have permission to write to the file. The reason you can't write to this file even though you added write permission is that you don't have write permission on the directory, but you must leave the directory permissions alone too. There is almost never a good reason to change the file modes of system directories. Just don't do it!

Instead perform the edit as root as in your original attempt. To use gedit:

sudo -H gedit /etc/apache2/apache2.conf

Since it's a graphical application we'll use -H to prevent root becoming owner of gedit's config files.

Do your thing, save and exit...

To use nano

sudo nano /etc/apache2/apache2.conf

Do your thing, then type Ctrl+O and then enter to write and then Ctrl+X to exit.


You are not running your GUI text editor as a superuser.

You could try pressing Alt + F2, and typing in:

pkexec env DISPLAY=$DISPLAY XAUTHORITY=$XAUTHORITY gedit /etc/apache2/apache2.conf

This will prompt for your password, then open a text editor with your specified file.

If you are using a different flavour/flavor of Ubuntu, you may want to try using pluma, kate, or leafpad instead of gedit.

Credit to this answer for getting pkexec to run a GUI application.

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.