Topic: Please clarify sudo vs. gksu/gksudo

I've always thought that using sudo to open an application was discouraged. For instance, instead of executing

sudo gedit file.txt

one should use

gksu gedit file.txt

I'd read that when opening an application with sudo, you'll be running it as root, but will use the user's configuration settings. If one changes any settings during this session, the respective configuration files will not only change, but their permissions will also change to root ownership. Conversely, gksu (or gksudo) resolves this and uses root's configuration for that application.

I found this website, which is brought up a lot on Ubuntu Forums when people ask this same question: http://www.psychocats.net/ubuntu/graphicalsudo

Am I wrong? Is sudo actually ok to use for opening an application?

Re: Please clarify sudo vs. gksu/gksudo

I always use sudo or gksudo.
sudo for CLI apps and gksudo for the "run program" window (alt+F2 in default CB). gksudo is just the graphic version of sudo.

Re: Please clarify sudo vs. gksu/gksudo

Exactly. My question, however, regards the way sudo and gksu actually execute.

I've done the test myself with "sudo firefox" and "gksu firefox" and got the same results as in the link I posted. But, I'm currently debating with someone else and could use some support. big_smile

Last edited by jollysnowman (2010-07-03 22:32:41)

Re: Please clarify sudo vs. gksu/gksudo

Like GuruX said, sudo for CLI apps and gksu(do) for graphical apps.

Note: ** Please read before posting **

BTW if you wish to contact me, send me an e-mail instead of a PM.

Re: Please clarify sudo vs. gksu/gksudo

The difference is gksu/gksudo (one is an alias for the other) pops up a dialog for the password, so you can use it outside of a terminal emulator; if you try running `sudo someprogram` from gmrun, xfce4-verve-plugin, or another application launcher, you won't get a dialog box, so nothing will happen unless you've already entered a sudouser password within the timeout period.

Aside from how they capture the sudouser password (CLI vs. dialog box) sudo and gksu/gksudo work exactly the same.

while ( ! ( succeed = try() ) );

Re: Please clarify sudo vs. gksu/gksudo

jollysnowman wrote:

Exactly. My question, however, regards the way sudo and gksu actually execute.

I've done the test myself with "sudo firefox" and "gksu firefox" and got the same results as in the link I posted. But, I'm currently debating with someone else and could use some support. big_smile

I've never noticed that before. I'm not able to test it today but sudo, gksudo or gksu should use the root configuration files.

Re: Please clarify sudo vs. gksu/gksudo

I'd always known it being as anonymous said and wasn't aware of the differences as you explained them, jollysnowman.  Guess I'll have to play around with that.  I will say one thing: during the short time I spent at Ubuntu Forums and having read http://www.psychocats.net if aysiu says something is, it probably is.

Re: Please clarify sudo vs. gksu/gksudo

well I don't use gksu but the kdesudo sourceforge page has always claimed it is a gui frontend for sudo, therefore no different in operation from the cli version, I doubt kdesudo works any differently than gksu.

Re: Please clarify sudo vs. gksu/gksudo

jollysnowman's explanation is correct. Using "sudo firefox" Firefox uses the profile in my home and using "gksudo firefox" will launch firefox as root. Both methods you will see Firefox with root's GTK theme however.

Note: ** Please read before posting **

BTW if you wish to contact me, send me an e-mail instead of a PM.

Re: Please clarify sudo vs. gksu/gksudo

In debian, running sudo iceweasel and changing the home page will result in that change being made only to roots home page and not the users.

In debian, it is perfectly fine to use sudo to run a graphical app.

As far as ubuntu, I have never managed to keep ubuntu installed for more than ten minutes before starting to heave violently and the only cure was immediately  formatting the partition. I think maybe it is genetic or something...



But, I'm currently debating with someone else and could use some support.

As someone once told me, it is always a good idea to put some thought into what you submit...especially if you are offering debian advice based on your ubuntu experience.

wink

Last edited by AnInkedSoul (2010-07-04 04:41:30)

refracta - a small bottle of debian magic

Re: Please clarify sudo vs. gksu/gksudo

anonymous wrote:

jollysnowman's explanation is correct. Using "sudo firefox" Firefox uses the profile in my home and using "gksudo firefox" will launch firefox as root. Both methods you will see Firefox with root's GTK theme however.

Oh ok, I thought we were just talking about gtk settings.

Re: Please clarify sudo vs. gksu/gksudo

AnInkedSoul wrote:

In debian, running sudo iceweasel and changing the home page will result in that change being made only to roots home page and not the users.

In debian, it is perfectly fine to use sudo to run a graphical app.

As far as ubuntu, I have never managed to keep ubuntu installed for more than ten minutes before starting to heave violently and the only cure was immediately  formatting the partition. I think maybe it is genetic or something...



But, I'm currently debating with someone else and could use some support.

As someone once told me, it is always a good idea to put some thought into what you submit...especially if you are offering debian advice based on your ubuntu experience.

wink

Hey! Go away!

Re: Please clarify sudo vs. gksu/gksudo

still waiting on you to test it wink

refracta - a small bottle of debian magic

Re: Please clarify sudo vs. gksu/gksudo

anonymous wrote:

jollysnowman's explanation is correct.

In ubuntu-land maybe, I wouldn't know as that is a scary place that I do not visit....

Everything is nice and sane in Debian-ville though...

refracta - a small bottle of debian magic

Re: Please clarify sudo vs. gksu/gksudo

Actually I tested it on Arch. I will test on Statler later.

Note: ** Please read before posting **

BTW if you wish to contact me, send me an e-mail instead of a PM.

Re: Please clarify sudo vs. gksu/gksudo

AnInkedSoul wrote:

In debian, running sudo iceweasel and changing the home page will result in that change being made only to roots home page and not the users.

In debian, it is perfectly fine to use sudo to run a graphical app.

Ok I tested it and heres why it happens on Debian. When you run sudo iceweasel or sudo firefox, Debian will detect this and will append the -h flag to sudo. This flag will make it use the root home folder instead of the user's home. To me, it seems like Debian trying to protect the user from himself/herself.

You shouldn't really run Iceweasel through sudo WITHOUT the -H option. Continuing as if you used the -H option.

Note: ** Please read before posting **

BTW if you wish to contact me, send me an e-mail instead of a PM.

Re: Please clarify sudo vs. gksu/gksudo

anonymous wrote:

... To me, it seems like Debian trying to protect the user from himself/herself.

...or do the 'right thing' that makes sense

refracta - a small bottle of debian magic

Re: Please clarify sudo vs. gksu/gksudo

@http://www.psychocats.net/ubuntu/graphicalsudo:

I've never experienced that sudo-uses-user-files problem. This text plays with words like the proper way or the improper way, like it was kanon...

Val_B wrote:

well I don't use gksu but the kdesudo sourceforge page has always claimed it is a gui frontend for sudo

It must be a sweet piece of software big_smile

I'm so meta, even this acronym