Is the difference between sudo cmd
and gksu cmd
, the same as the difference
between starting a shell with sudo -i
and sudo -s
?
... or put another way,
Is sudo cmd
the same as sudo -i cmd
and gksu cmd
the same as sudo -s cmd
?
EDIT: Based on what I read on an Ubuntu Documentation Page where it says:
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).
The "AFAICT" doen't really give me full confidence that there is nothing more to it.
(..a belated UPDATE: I tested his commemnt today (2 months later) about:
"This prevents files in your home directory becoming owned by root."
All files I created via sudo/gksu were all owned by "root", and the group was "root".)
I've read parts of the info sudo
and noticed the -i
and -s
seem to be doing the same thing as the AFAICT environment issue...
but I hit overload.. so I've asked my question here.
PS.. My question is not about sudo vs gksu
.. It is more about: Is gksu the same as sudo -s
.. and if not, how do they differ?
gksu
is basically a graphical frontend for sudo that allows graphical command to be run without the need to run an X terminal emulator and using su directly. It's effectively just a GTK+ skin for the superuser commands.So if you wanted to run a GUI based program as root, you would invoke it with
gksu cmd
, rather thansudo cmd
, which is used for invoking console programs as root.sudo -i
resets the login environment to the target user (root, in this case). Mainly, it is that theHOME
environment variable is changed, which means the target user's~/.bashrc
is loaded.gksu
is, therefore, likesudo -i
in that is switches$HOME
to the root user.This isn't really an answer, but it may be of some interest...
I'm starting to get an idea of what goes on with these su commands,
but I'm not quite there yet... I do use
gksu
... This is more a journey of understanding for me... and I wan't to understand ifgksu
is valid forkonsole
orkate
, or must I use the KDE variantkdesu
..Here are some results of some tests I've just tried.
These results don't agree with the Ubuntu Documentation Page, where it says:
UPDATE: The XAUTHORITY
env
variables for the sudo and gksu invoked Terminals are different (as mentioned on the Ubuntu Documentation Page) ..This shows that
gksu
is definitely not the same as thesudo -s
command I referred to in the question ... and therefore anwers my otiginal question (in some still obscure way) ... and Chris's answer certainly got me thinking hard on this one! ... I need a coffee!!sudo is for command line apps, gksu/gksudo for graphical ones