PDA

View Full Version : [SOLVED] How do you launch a program as root user under unity?



Randy Schilling
June 8th, 2012, 04:06 AM
I would like to open certain programs, such as gedit and the command-line interface,
from the unity launcher both as regular user and as root (administrator) user.
I had this set up under Ubuntu 11.04 using a program called Main
(or something???) but I can't seem to find this program under 12.04.
Is there an easy way to set this up?
Thanks, so fortunate to have this help forum. Regards - Randy

wilee-nilee
June 8th, 2012, 04:22 AM
Here is the forums policy on this.

http://ubuntuforums.org/showthread.php?t=1486138

davetv
June 8th, 2012, 05:12 AM
Here is the forums policy on this.

http://ubuntuforums.org/showthread.php?t=1486138


Hi Wilee-nilee. I think the OP is asking for a unity equivalent of gksu or kdesu

wilee-nilee
June 8th, 2012, 05:28 AM
Hi Wilee-nilee. I think the OP is asking for a unity equivalent of gksu or kdesu

Partially, maybe read closer.

mcduck
June 8th, 2012, 11:35 AM
I would like to open certain programs, such as gedit and the command-line interface,
from the unity launcher both as regular user and as root (administrator) user.
I had this set up under Ubuntu 11.04 using a program called Main
(or something???) but I can't seem to find this program under 12.04.
Is there an easy way to set this up?
Thanks, so fortunate to have this help forum. Regards - Randy

For any graphical applications, just add "gksudo" in front of the command you'd normally use to launch the application.

(If you want to create new launchers for this purpose, install "Alacarte", it's the tool Gnome desktop uses for editing menu items. Once installed, it will appear with the name "Main Menu" in your menus (or in Unity's Dash).

...and for terminal, running "sudo -i" will start a root session. "exit" will return you back to normal user again.

For more detailed information, you should read this document: https://help.ubuntu.com/community/RootSudo

Frogs Hair
June 8th, 2012, 02:32 PM
Bleach bit is the only application I have installed that comes with a root and regular user option . I have created a Nautilus Root launcher with main menu after installing Alacarte and adding the new item . Now I just get a password prompt when using the Icon instead of using the terminal.

Randy Schilling
June 8th, 2012, 04:22 PM
What I was looking for was the "Main Menu".
I could not recall that it is installed as "Alacarte".
Thanks Mcduck.

The problem I have with the use of gksu to launch a
graphical application such as nautilus from a terminal
is that it locks your terminal to that app, leaving you
with two windows on your desktop to run a single app.


I was not aware of sudo -i as a way to access the root prompt #.
I use to do this with "sudo gnome-terminal" or "gksu gnome-terminal".
I like "sudo -i" because it does not add another terminal to your desktop.
I'm surprised that it does not ask for a password.

I don't understand the difference between sudo and gksu. gksu seems
to be used with graphical apps and sudo is apparently not restricted.
In my experience they're completely interchangeable.

Thanks as always for your help.

mcduck
June 8th, 2012, 04:34 PM
What I was looking for was the "Main Menu".
I could not recall that it is installed as "Alacarte".
Thanks Mcduck.

The problem I have with the use of gksu to launch a
graphical application such as nautilus from a terminal
is that it locks your terminal to that app, leaving you
with two windows on your desktop to run a single app.


I was not aware of sudo -i as a way to access the root prompt #.
I use to do this with "sudo gnome-terminal" or "gksu gnome-terminal".
I like "sudo -i" because it does not add another terminal to your desktop.
I'm surprised that it does not ask for a password.

I don't understand the difference between sudo and gksu. gksu seems
to be used with graphical apps and sudo is apparently not restricted.
In my experience they're completely interchangeable.

Thanks as always for your help.

to prevent an GUI app from locking a temrinal when launched, you simply need to tell the shell to launch it in the background. For example:

gksudo gedit &

Some programs might still output errors and other messages to the temrinal, if you want to prevent that you can use the "nohup" command:

nohup gksudo gedit &
This will redirect the output to a textfile in your home directory, and also allows you to close the terminal without the program getting closed automatically with it.

What comes to "sudo -i" asking for password, it does, but duso has a built-in timeout mechanism so if you've used sudo recently, it's not going to ask you for password again until certain time has elapsed.

MG&TL
June 8th, 2012, 04:41 PM
Following on from mcduck,

If you want closing the terminal to have no effect on the app, follow the command with "disown"-example:


gedit &
#closing the terminal now will kill the app


gedit &
disown
#closing the terminal now has no effect

IWantFroyo
June 8th, 2012, 04:46 PM
Following on from mcduck,

If you want closing the terminal to have no effect on the app, follow the command with "disown"-example:


gedit &
#closing the terminal now will kill the app


gedit &
disown
#closing the terminal now has no effect

Odd. I can start a program with the "gedit &" method, and then just close the terminal.

MG&TL
June 8th, 2012, 04:57 PM
Odd. I can start a program with the "gedit &" method, and then just close the terminal.

Okay, that's weird. I don't personally have gedit installed, maybe it forks itself?

IWantFroyo
June 8th, 2012, 04:59 PM
Okay, that's weird. I don't personally have gedit installed, maybe it forks itself?

I'm not just talking about gedit. I can open any program, and as long as I add the "&", it becomes independent. :|

MG&TL
June 8th, 2012, 05:00 PM
I'm not just talking about gedit. I can open any program, and as long as I add the "&", it becomes independent. :|

The only other thing I can think of is what shell and terminal emulator do you use? I've got bash and lxterminal.

Randy Schilling
June 9th, 2012, 12:51 AM
Yes, & to "disconnect" program from terminal.
Now I know what it means to run a program in the "background".
I too could not see that that "disown" made any difference.

Thanks