2

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"

Sigh...

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

AARRGH!

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?

2 Answers2

5

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.

Zanna
  • 70,465
0

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.

luk3yx
  • 401