0

I have a problem with editing config files. E.g. in the opt/ folder. I understand that I need to do this as root. But even with

sudo gedit path/filename

it doesn’t work (see screenshot).

With sudoedit I could edit the file but when I tried to save it (overwrite the old one) I got the error message „no permission“.

I have the permission to execute sudo since „sudo -i“ works (see second pic).

I tried gedit admin/// as well. Didn’t work as well.

Of course, I tried to edit the file with a graphical editor as well. Same result.

And I tried to edit other config files (e.g. in etc/): same result.

What am I doing wrong?

(I’m a beginner with Ubuntu/Linux, so, excuse if it’s an easy to solve mistake, what I hope for!)

command sudo -i works

error message on sudo gedit command

1 Answer 1

0

We never use sudo with graphical applications. That makes a graphical application run in the environment of the user with root priviledges. That may cause changes in permissions etc. that can prevent you from logging in.

The "official" way in Ubuntu to use a graphical editor for editing system files is with the admin:/// URI, but I myself also find that unelegant, with two passwords dialogs appearing etc.

A good approach would be

EDITOR=gedit -s sudoedit /path/filename

This copies the system file to a temporary file that you edit as normal user. When the editor is closed, the system file is updated. The -s option ensures a separate instance of gedit is used, i.e., it will not connect to an existing instance so possible problems are avoided.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .