How to use sudo and a graphical program?

NoOp glgxg at sbcglobal.net
Thu May 3 00:00:57 UTC 2012


On 05/02/2012 07:00 AM, Kevin O'Gorman wrote:
> I guess I don't understand access permissions to my display.
> 
> If I become root via "sudo su -", I cannot use gedit or gvim because
> they are unable to open the display.

Works for me:

$ sudo -i
# gedit
# gvim

(Unbuntu 11.04, 11.10, 12.04)

> 
> If I start them as "sudo gedit somefile" it works, but when I'm doing
> serious admin work, I consider this tedious.

Ummm, in standard user you should be using gksudo or kdesudo instead:

https://help.ubuntu.com/community/RootSudo
http://ubuntuforums.org/showpost.php?p=6188826&postcount=4

You've been notified about this before & I consider reminding you of
this tedious.

For new users to this list/Ubuntu, I'll quote from
<https://help.ubuntu.com/community/RootSudo>:

<quote>
Graphical sudo

You should *never* use normal sudo to start graphical applications as
Root. You should use gksudo (kdesudo on Kubuntu) to run such programs.
gksudo sets HOME=~root, and copies .Xauthority to a tmp directory. This
prevents files in your home directory becoming owned by Root. (AFAICT,
this is all that's special about the environment of the started process
with gksudo vs. sudo).

Examples:

gksudo gedit /etc/fstab

or

kdesudo kate /etc/X11/xorg.conf
</quote>

> 
> I'm not complaining so much as wanting to understand.  Any clues?
> 

Try letting others know what/if error messages you get?

-- 
Gary Lee, AS CS





More information about the ubuntu-users mailing list