LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Newbie (https://www.linuxquestions.org/questions/linux-newbie-8/)
-   -   How can I double click and open application with sudo permission (https://www.linuxquestions.org/questions/linux-newbie-8/how-can-i-double-click-and-open-application-with-sudo-permission-760760/)

blurboy 10-09-2009 08:30 AM

How can I double click and open application with sudo permission
 
I have an application that can be opened in Terminal by entering the following command:
sudo ./MyApplication

The Terminal will then prompt me for my sudo password which I will need to enter manually.
And the program will run.

Is there any ways where I can just double click my application icon and run it directly with sudo permissions? Can I set it in the properties to automatically run it with sudo permissions which is something like setting "Run the program as an Administrator"?

Agrouf 10-09-2009 08:38 AM

create a file containing the text:
Code:

sudo MyApplication
give it execute permission and you can double click on it.

lutusp 10-09-2009 02:30 PM

Quote:

Originally Posted by blurboy (Post 3713425)
I have an application that can be opened in Terminal by entering the following command:
sudo ./MyApplication

The Terminal will then prompt me for my sudo password which I will need to enter manually.
And the program will run.

Is there any ways where I can just double click my application icon and run it directly with sudo permissions? Can I set it in the properties to automatically run it with sudo permissions which is something like setting "Run the program as an Administrator"?

No, to use sudo you must enter a password -- always. And sudo won't allow you to give it a password without user interaction. So the trick is to figure out how to enter a password after clicking a desktop icon.

Here's one way -- put this into a shell script:

Code:

kdesu (program name)
-- or, for Gnome --

Code:

gnomesu (program name)
This will launch a dialog that asks for a password.

Widgeteye 10-09-2009 02:50 PM

Quote:

No, to use sudo you must enter a password -- always. And sudo won't allow you to give it a password without user interaction. So the trick is to figure out how to enter a password after clicking a desktop icon.
Wrong.

edit /etc/sudoers and put the following in it:

# User privilege specification
root ALL=(ALL) ALL
yourname ALL=(ALL) NOPASSWD: ALL

DarkeKun 10-09-2009 03:51 PM

what should I use to edit it with?

smeezekitty 10-09-2009 04:28 PM

any text editor ! duh !

blurboy 10-09-2009 04:42 PM

Quote:

Originally Posted by lutusp (Post 3713820)
No, to use sudo you must enter a password -- always. And sudo won't allow you to give it a password without user interaction. So the trick is to figure out how to enter a password after clicking a desktop icon.

Here's one way -- put this into a shell script:

Code:

kdesu (program name)
-- or, for Gnome --

Code:

gnomesu (program name)
This will launch a dialog that asks for a password.

this method dont work. it did prompt for a password. but it is the root password. I am using sudo all along.. root is not enable. there is no root password

DarkeKun 10-09-2009 05:02 PM

Quote:

Originally Posted by smeezekitty (Post 3713942)
any text editor ! duh !

Thanks, and sorry because im new to this, but what text editor, i dont know anything here..

smeezekitty 10-09-2009 05:09 PM

do you know how confusing it is to help 2 people at once?
i am booting Ubuntu (shutter) now to see what you can use

blurboy 10-09-2009 05:09 PM

Quote:

Originally Posted by Widgeteye (Post 3713842)
Wrong.

edit /etc/sudoers and put the following in it:

# User privilege specification
root ALL=(ALL) ALL
yourname ALL=(ALL) NOPASSWD: ALL

follow what you said. edited the file using sudo vi /etc/sudoers

when i type sudo ./MyApplication it still ask me for my password.

what I need is to be able to run MyApplication when I double click the icon and run with sudo permission.

smeezekitty 10-09-2009 05:13 PM

ok type sudo gedit at the terminal

blurboy 10-09-2009 06:13 PM

ok i have solve my problem by creating a shell script file with the command "gksudo MyApplication" inside. By double clicking this file i can run my application with sudo permissions.. it will have a dialog box prompting me to enter the password at least =)

Widgeteye 10-09-2009 06:38 PM

OK, you have to edit the file using "visudo" as root.
type visudo sudoers

then make the changes and save. you have to edit with "visudo"

It says right in the file how to edit.

lutusp 10-09-2009 08:52 PM

Quote:

Originally Posted by Widgeteye (Post 3713842)
Wrong.

edit /etc/sudoers and put the following in it:

# User privilege specification
root ALL=(ALL) ALL
yourname ALL=(ALL) NOPASSWD: ALL

Okay, let me rephrase -- everyone should always enter a password for sudo. To dismantle this protection is utterly brainless.

lutusp 10-09-2009 08:56 PM

Quote:

Originally Posted by blurboy (Post 3713954)
this method dont work. it did prompt for a password. but it is the root password. I am using sudo all along.. root is not enable. there is no root password

What? Yes, there is a root password, or if not, you need to set one now.

Don't you understand that "sudo" requires the root password, and that when sudo is enabled, you become root?

Logging on as root, and using "sudo", both give you root privileges. The latter is preferred.


All times are GMT -5. The time now is 07:13 PM.