Proper way to open apps as root in X

Share your own howto's etc. Not for support questions!

Proper way to open apps as root in X

Postby craigevil » 2010-07-03 08:55

There are various ways to open apps as root in X. The method that is used can vary depending on the graphical login manager gdm/kdm/xdm/slim in use.

Some apps are already setup to open as root such as Synaptic, gparted, and Root Terminal. Normally they use something like su-to-root -X -c. Synaptic is one app that I can think of that does it that way, if you look at Synaptic in /usr/share/applications and open it with a text editor you see Exec=su-to-root -X -c /usr/sbin/synaptic.

sux - wrapper around su which will transfer your X credentials
Proper use of sux (note not installed by default):
Code: Select all
 sux

Password:
root@craigevil:/home/craig# gedit

su - change user ID or become superuser
You can use su like this:
Code: Select all
su -
Note the hyphen -
Password:
root@craigevil:~# gedit

gksu - GTK+ frontend for su and sudo
gksu is a frontend to su and gksudo is a frontend to sudo.
Their primary purpose is to run graphical commands that need root without the need to run an X terminal emulator and using su directly.
Proper gksu use:
Code: Select all
gksu gedit

window pops up asking for root password, then gedit opens.

kdesu - Runs a program with elevated privileges
Proper kdesu use in KDE:
Code: Select all
kdesu kwrite

window popsup up asking for root password, then kwrite opens.

sudo, sudoedit - execute a command as another user
sudo allows a permitted user to execute a command as the superuser or another user, as specified in the sudoers file.
Note sudo is installed on most Debian installs but is not setup in order to use sudo it needs to be setup properly using visudo.
Sudo Setup Guide - http://www.linuxhelp.net/guides/sudo/
Using sudo - http://aplawrence.com/Basics/sudo.html
sudo - Debian Wiki - http://wiki.debian.org/sudo

To keep from having issues with permissions please use gksudo or kdesudo.
See Running Sudo Graphically - http://www.psychocats.net/ubuntu/graphicalsudo for why.
Code: Select all
gksudo foo

Code: Select all
kdesudo foo



You can also use most file managers to navigate to the file you want to edit then right click and choose Edit as root. Or in the case of pcmanfm, Tools>open folder as root then click the file to edit with the default text editor. Nautilus and Konqueror have open as root and edit as root options.
If not you can download "service menus" from places like
http://kde-apps.org/
http://gtk-apps.org/
http://www.gnomefiles.org/
http://cli-apps.org/

Each command has a man page:
man sux
man sudo
man gksu
man kdesu
man su

Other helpful links:
Disallow SuToRoot on Debian - wiki.welmers.net - http://wiki.welmers.net/en/Disallow_SuToRoot_on_Debian
sudo setup - viewtopic.php?f=16&t=45390
Providing root privileges for users Using SUDO -- Debian Admin - http://www.debianadmin.com/providing-ro ... -sudo.html
Debian Sid KDE Kernel 3.17 Thinkpad R40 Intel M 1.3 CPU 2GB RAM Radeon Mobility 7500
Debian - "If you can't apt-get something, it isn't useful or doesn't exist"
Debian upgrade script smxi | sysinfo script inxi
User avatar
craigevil
 
Posts: 5161
Joined: 2006-09-17 03:17
Location: Oz

Re: Proper way to open apps as root in X

Postby secipolla » 2010-07-03 14:06

Thanks. There's gksudo as well.
secipolla
 
Posts: 1127
Joined: 2010-06-21 14:20

Re: Proper way to open apps as root in X

Postby craigevil » 2010-07-03 14:10

Debian -- Package Search Results -- gksudo
You have searched for packages that names contain gksudo in all suites, all sections, and all architectures.

Sorry, your search gave no results
Debian Sid KDE Kernel 3.17 Thinkpad R40 Intel M 1.3 CPU 2GB RAM Radeon Mobility 7500
Debian - "If you can't apt-get something, it isn't useful or doesn't exist"
Debian upgrade script smxi | sysinfo script inxi
User avatar
craigevil
 
Posts: 5161
Joined: 2006-09-17 03:17
Location: Oz

Re: Proper way to open apps as root in X

Postby jollysnowman » 2010-07-03 15:00

I thought sudo shouldn't be used for opening applications (as opposed to doing stuff on the command line)? I remember reading somewhere that when sudo opens an application, it uses the user's config settings for that application instead of root's and bad things happen.

Edit: Also, gksudo exists. I've definitely seen it in Ubuntu.

Edit #2: http://www.psychocats.net/ubuntu/graphicalsudo
jollysnowman
 
Posts: 134
Joined: 2009-08-29 19:42
Location: Austin, TX

Re: Proper way to open apps as root in X

Postby smallchange » 2010-07-03 16:53

I have had
xhost SI:localuser:root
in my .xinitrc file for so long my info may be out of date but doesn't Debian default to not allowing root to use the display when using "su"?
smallchange
 
Posts: 1740
Joined: 2009-05-04 15:56

Re: Proper way to open apps as root in X

Postby AnInkedSoul » 2010-07-03 17:10

jollysnowman wrote:I thought sudo

You should rethink :P

gksudo exists

gksu is the real program and gksudo is a 'fake' program that links to gksu
AnInkedSoul
 
Posts: 461
Joined: 2010-06-11 05:05

Re: Proper way to open apps as root in X

Postby nadir » 2010-07-03 17:28

smallchange wrote:I have had
xhost SI:localuser:root
in my .xinitrc file for so long my info may be out of date but doesn't Debian default to not allowing root to use the display when using "su"?

Heavy stuff... but:
I think it is rather the display-manager (gdm, kdm, etc) which does that per default. No display-manager, no problems with that. At least here.
"I am not fine with it, so there is nothing for me to do but stand aside." M.D.
User avatar
nadir
 
Posts: 5965
Joined: 2009-10-05 22:06
Location: away

Re: Proper way to open apps as root in X

Postby jollysnowman » 2010-07-03 20:25

AnInkedSoul wrote:
jollysnowman wrote:I thought sudo

You should rethink :P


Can you elaborate? As it is, your post doesn't really help.
jollysnowman
 
Posts: 134
Joined: 2009-08-29 19:42
Location: Austin, TX

Re: Proper way to open apps as root in X

Postby jheaton5 » 2010-07-03 20:38

jollysnowman wrote:
AnInkedSoul wrote:
jollysnowman wrote:I thought sudo

You should rethink :P


Can you elaborate? As it is, your post doesn't really help.

Come on. He gave you the command
Code: Select all
$ gksudo <command>

And you don't have to do this from the terminal either. <alt><f2> will pop up a dialogue box, type your command in that box.
debian sid with kernel img 3.8.10 lxde no dm
User avatar
jheaton5
 
Posts: 1475
Joined: 2008-08-20 01:40
Location: Sharpsburg, GA, USA

Re: Proper way to open apps as root in X

Postby jollysnowman » 2010-07-03 20:50

jheaton5 wrote:Come on. He gave you the command
Code: Select all
$ gksudo <command>

And you don't have to do this from the terminal either. <alt><f2> will pop up a dialogue box, type your command in that box.


This thread is about opening apps as root in X. If you look at the link I posted, you'll see that applications opened with sudo modify the user's (not root's) permissions in their home directory.
jollysnowman
 
Posts: 134
Joined: 2009-08-29 19:42
Location: Austin, TX

Re: Proper way to open apps as root in X

Postby jheaton5 » 2010-07-03 21:01

jollysnowman wrote:
jheaton5 wrote:Come on. He gave you the command
Code: Select all
$ gksudo <command>

And you don't have to do this from the terminal either. <alt><f2> will pop up a dialogue box, type your command in that box.


This thread is about opening apps as root in X. If you look at the link I posted, you'll see that applications opened with sudo modify the user's (not root's) permissions in their home directory.

Code: Select all
$ gksu <command>

typed gksudo by mistake.
debian sid with kernel img 3.8.10 lxde no dm
User avatar
jheaton5
 
Posts: 1475
Joined: 2008-08-20 01:40
Location: Sharpsburg, GA, USA

Re: Proper way to open apps as root in X

Postby AnInkedSoul » 2010-07-03 21:31

jollysnowman wrote:... applications opened with sudo modify the user's (not root's) permissions in their home directory.

wrong
AnInkedSoul
 
Posts: 461
Joined: 2010-06-11 05:05

Re: Proper way to open apps as root in X

Postby jollysnowman » 2010-07-03 22:04

AnInkedSoul wrote:
jollysnowman wrote:... applications opened with sudo modify the user's (not root's) permissions in their home directory.

wrong


Please explain, because you are not being helpful. Also, consider the link I pasted earlier: http://www.psychocats.net/ubuntu/graphicalsudo

I've read that sudo is not recommended for opening applications many times, and you are the first, in my experience, to say otherwise. So please, explain. If I'm wrong, I'm wrong. I'm not looking for an argument.
jollysnowman
 
Posts: 134
Joined: 2009-08-29 19:42
Location: Austin, TX

Re: Proper way to open apps as root in X

Postby AnInkedSoul » 2010-07-03 22:13

open a terminal and type in sudo iceweasel and set the homepage to flapjack.com
now close it

as a user, open iceweasel.....no flapjack.com
AnInkedSoul
 
Posts: 461
Joined: 2010-06-11 05:05

Re: Proper way to open apps as root in X

Postby jollysnowman » 2010-07-03 22:50

I did, and got the same results as in the link I posted. I tried it in CrunchBang 9.04, which is Ubuntu-based.
jollysnowman
 
Posts: 134
Joined: 2009-08-29 19:42
Location: Austin, TX

Next

Return to Docs, Howtos, Tips & Tricks

Who is online

Users browsing this forum: No registered users and 11 guests

fashionable