PDA

View Full Version : [ubuntu] sudo gedit issue after upgrading to 18.04 from 16.04?



daition
April 30th, 2018, 04:26 AM
As shown in the picture attached, when issuing "sudo gedit" in terminal, the content of gedit is just a snapshot of my desktop instead of a new document. Launching gedit without sudo is good.

I also tried with pluma. The behaviors are the same as I describe above.

Anyone can help?

joegry
April 30th, 2018, 05:26 AM
Can you try sudo gedit ~/test.txt to see if it will open a new file correctly when specifying a filename?

Xian
April 30th, 2018, 05:45 AM
For more detailed info read:

http://www.webupd8.org/2015/03/how-to-run-gedit-and-nautilus-as-root.html


The basic steps are to swtich from gksu to pkexec:


sudo apt-get install nautilus-admin


wget https://raw.githubusercontent.com/hotice/webupd8/master/org.gnome.gedit.policy -O /tmp/org.gnome.gedit.policy


sudo cp /tmp/org.gnome.gedit.policy /usr/share/polkit-1/actions/


pkexec gedit

daition
April 30th, 2018, 06:01 AM
Specifying a filename doesn't change anything. The behavior is the same.

daition
April 30th, 2018, 06:05 AM
For more detailed info read:

http://www.webupd8.org/2015/03/how-to-run-gedit-and-nautilus-as-root.html


The basic steps are to swtich from gksu to pkexec:


sudo apt-get install nautilus-admin


wget https://raw.githubusercontent.com/hotice/webupd8/master/org.gnome.gedit.policy -O /tmp/org.gnome.gedit.policy


sudo cp /tmp/org.gnome.gedit.policy /usr/share/polkit-1/actions/


pkexec gedit

Thank you for your reply.

I tried the steps above. But it doesn't work. The problem remains...

Xian
April 30th, 2018, 06:22 AM
Well ... there's a fly in the ointment somewhere.

When you execute the command:


pkexec gedit

Does a GUI dialogue box appear asking for your sudo password?

If it does and still gedit won't open what is the terminal output?

https://i.imgur.com/KsJC7vzm.png

wildmanne39
April 30th, 2018, 06:29 AM
Please try:

sudo -H gedit
There have been changes in 18.04, gksu was removed, here is a link that will help.

You should never have run a GUI application with sudo in previous versions of ubuntu either because you run the risk of root taking ownership.

https://ubuntuforums.org/showthread.php?t=2389656

monkeybrain20122
April 30th, 2018, 06:34 AM
How about this

gedit admin:// ...

... is the FULL PATH to your file to be edited.

In other words instead of using sudo or gksudo , prepend the full path with admin://

e.g if you want to edit your sources list

instead of

gksudo gedit /etc/apt/sources.list

now


gedit admin:///etc/apt/sources.list


Apparently using relative path doesn't work. I.e, before you could do

cd /etc/apt
gksudo gedit sources.list

but neither of the followings work


cd /etc/apt
gedit admin://sources.list



cd /etc/apt
gedit admin://./sources.list

monkeybrain20122
April 30th, 2018, 06:36 AM
Please try:

sudo -H gedit
There have been changes in 18.04, gksu was removed, here is a link that will help.

You should never have run a GUI application with sudo in previous versions of ubuntu either because you run the risk of root taking ownership.

https://ubuntuforums.org/showthread.php?t=2389656

This appears to be the cleanest way. thanks!

monkeybrain20122
April 30th, 2018, 06:39 AM
For more detailed info read:

http://www.webupd8.org/2015/03/how-to-run-gedit-and-nautilus-as-root.html


The basic steps are to swtich from gksu to pkexec:


sudo apt-get install nautilus-admin


wget https://raw.githubusercontent.com/hotice/webupd8/master/org.gnome.gedit.policy -O /tmp/org.gnome.gedit.policy


sudo cp /tmp/org.gnome.gedit.policy /usr/share/polkit-1/actions/


pkexec gedit


That sounds crazy to expect users to create or download policy files from third parties just to get a basic functionality, if this is the way to run pkexec it just encourages people to abuse sudo.

wildmanne39
April 30th, 2018, 06:45 AM
I think it is a lot to go through and sudo -H is safe so that is what I will stick with, here is an article by the developer that removed gksu.

https://jeremy.bicha.net/2018/04/18/gksu-removed-from-ubuntu/

Your welcome!

again?
April 30th, 2018, 09:29 AM
For a right click menu item, the nautilus-admin package has been updated to use "admin://"

sudo apt install nautilus-admin