Scheduled Maintenance: We are aware of an issue with Google, AOL, and Yahoo services as email providers which are blocking new registrations. We are trying to fix the issue and we have several internal and external support tickets in process to resolve the issue. Please see: viewtopic.php?t=158230

 

 

 

Proper way to open apps as root in X

Share your HowTo, Documentation, Tips and Tricks. Not for support questions!.
Message
Author
User avatar
craigevil
Posts: 5391
Joined: 2006-09-17 03:17
Location: heaven
Has thanked: 28 times
Been thanked: 39 times

Proper way to open apps as root in X

#1 Post by craigevil »

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 - http://forums.debian.net/viewtopic.php?f=16&t=45390
Providing root privileges for users Using SUDO -- Debian Admin - http://www.debianadmin.com/providing-ro ... -sudo.html
Raspberry PI 400 Distro: Raspberry Pi OS Base: Debian Sid Kernel: 5.15.69-v8+ aarch64 DE: MATE Ram 4GB
Debian - "If you can't apt install something, it isn't useful or doesn't exist"
My Giant Sources.list

secipolla
Posts: 1127
Joined: 2010-06-21 14:20

Re: Proper way to open apps as root in X

#2 Post by secipolla »

Thanks. There's gksudo as well.

User avatar
craigevil
Posts: 5391
Joined: 2006-09-17 03:17
Location: heaven
Has thanked: 28 times
Been thanked: 39 times

Re: Proper way to open apps as root in X

#3 Post by craigevil »

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
Raspberry PI 400 Distro: Raspberry Pi OS Base: Debian Sid Kernel: 5.15.69-v8+ aarch64 DE: MATE Ram 4GB
Debian - "If you can't apt install something, it isn't useful or doesn't exist"
My Giant Sources.list

jollysnowman
Posts: 134
Joined: 2009-08-29 19:42
Location: Austin, TX

Re: Proper way to open apps as root in X

#4 Post by jollysnowman »

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

smallchange
Posts: 1740
Joined: 2009-05-04 15:56
Been thanked: 1 time

Re: Proper way to open apps as root in X

#5 Post by smallchange »

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"?

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

Re: Proper way to open apps as root in X

#6 Post by AnInkedSoul »

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

User avatar
nadir
Posts: 5961
Joined: 2009-10-05 22:06
Location: away

Re: Proper way to open apps as root in X

#7 Post by nadir »

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.

jollysnowman
Posts: 134
Joined: 2009-08-29 19:42
Location: Austin, TX

Re: Proper way to open apps as root in X

#8 Post by jollysnowman »

AnInkedSoul wrote:
jollysnowman wrote:I thought sudo
You should rethink :P
Can you elaborate? As it is, your post doesn't really help.

User avatar
jheaton5
Posts: 1488
Joined: 2008-08-20 01:40
Location: Newnan, GA, USA

Re: Proper way to open apps as root in X

#9 Post by jheaton5 »

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

jollysnowman
Posts: 134
Joined: 2009-08-29 19:42
Location: Austin, TX

Re: Proper way to open apps as root in X

#10 Post by jollysnowman »

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.

User avatar
jheaton5
Posts: 1488
Joined: 2008-08-20 01:40
Location: Newnan, GA, USA

Re: Proper way to open apps as root in X

#11 Post by jheaton5 »

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

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

Re: Proper way to open apps as root in X

#12 Post by AnInkedSoul »

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

jollysnowman
Posts: 134
Joined: 2009-08-29 19:42
Location: Austin, TX

Re: Proper way to open apps as root in X

#13 Post by jollysnowman »

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.

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

Re: Proper way to open apps as root in X

#14 Post by AnInkedSoul »

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

jollysnowman
Posts: 134
Joined: 2009-08-29 19:42
Location: Austin, TX

Re: Proper way to open apps as root in X

#15 Post by jollysnowman »

I did, and got the same results as in the link I posted. I tried it in CrunchBang 9.04, which is Ubuntu-based.

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

Re: Proper way to open apps as root in X

#16 Post by AnInkedSoul »

jollysnowman wrote:I did, and got the same results as in the link I posted. I tried it in CrunchBang 9.04, which is Ubuntu-based.
well this is the debian user forums and here we discuss debian....sorry

jollysnowman
Posts: 134
Joined: 2009-08-29 19:42
Location: Austin, TX

Re: Proper way to open apps as root in X

#17 Post by jollysnowman »

AnInkedSoul wrote:
jollysnowman wrote:I did, and got the same results as in the link I posted. I tried it in CrunchBang 9.04, which is Ubuntu-based.
well this is the debian user forums and here we discuss debian....sorry
I can test it on debian later, but I don't think there would be a different implementation of sudo in debian, especially since Ubuntu is debian-based. Either way, I'll report later.

AnInkedSoul, I really advise you to be more helpful in your posts. I asked you to elaborate, and you gave me a one word response. I'm not a troll, and I do my best to remain friendly, if a bit dry; I've already had my fair share of Internet debates in a handful of different forums. Providing a meaningless post is the same as not providing one at all. You would do everyone a favor by putting some thought into what you submit.

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

Re: Proper way to open apps as root in X

#18 Post by AnInkedSoul »

I am being concise. Nothing meaningless about it. A sufficient answer is sufficient.

User avatar
Jackiebrown
Posts: 1246
Joined: 2007-01-02 04:46
Location: San Antonio, TX

Re: Proper way to open apps as root in X

#19 Post by Jackiebrown »

jollysnowman wrote:I did, and got the same results as in the link I posted. I tried it in CrunchBang 9.04, which is Ubuntu-based.
That happens to me as well. It was a real issue when you use sudo to run an installer and the installer launched the game for you. You had to go back and change the the ownership in your home file (/home/user/.doom3) to yourself unless you wanted to always have to play the game as root.

Heck, this happened to me with dolphin once (i ran sudo dolphin before ever running it as a user) and really messed with my kde install. It took me a while to figure out why dolphin wouldn't start after that.

That said, this was in ubuntu for me as well. Maybe it is different for ubuntu since there is no root account for it to use. When I set up sudo in debian, it is for specific programs that I would probably never run as a regular user (synaptic comes to mind.)

User avatar
mzilikazi
Forum Account
Forum Account
Posts: 3282
Joined: 2004-09-16 02:14
Location: Colorado Springs, CO

Re: Proper way to open apps as root in X

#20 Post by mzilikazi »

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.
What he's saying is that gksudo is just a link to the real executable gksu. This is apparently an Ubuntu thing. Check for yourself:

Code: Select all

ls -al $(which gksudo) 
Debian Sid Laptops:
AMD Athlon(tm) 64 X2 Dual-Core Processor TK-55 / 1.5G
Intel(R) Pentium(R) Dual CPU T2390 @ 1.86GHz / 3G

Post Reply