Take the 2-minute tour ×
Ask Ubuntu is a question and answer site for Ubuntu users and developers. It's 100% free, no registration required.

I want have a script that I can give to friends which will add repositories and download files, install them without having to use command as they are not command line savey and have no desire to learn. I need to know how to get the script to prompt them for the root password to allow them to do some of these functions. How would I go about this? Please don't hate on them.. Getting them to start using Linux was a big step and I am just happy that they are attempting something new... and it was in the open source world..

share|improve this question
    
Thank you both. It's funny at how obvious that was and I overlooked a simple command; gksu. I think that may work for what I am attempting. Thanks to both of you. –  VinceBrowning Oct 12 '12 at 10:02
    
Just to have it mentioned: its exactly the purpose of Ubuntu Software Center to let people who are not comfortable with the command line install applications or add repositories. –  Takkat Oct 12 '12 at 10:35
add comment

1 Answer

Just use the sudo word in front of the command in the bash script. And when you execute the file, select "Open in terminal", you will be asked for password.

For example, if you are using apt-get commands , you can use like this

#!/bin/sh
sudo apt-get update
sudo apt-get upgrade
.....
.....

If need to make this executable and when you double click there will be a prompt like this

enter image description here

You need to click on Open in terminal button and provide password in the terminal

Update

As Karthick T commented, you can also use the gksu or gksudo word before the command. So, the file could be

gksu apt-get update
gksudo apt-get install <some-package>

Double clicking the script will ask the password and run the command after you provided it.

share|improve this answer
1  
or gksu if they want to run it without terminal ( Run option) –  Karthik T Oct 12 '12 at 9:52
    
@OliveTwist Just for future reference, can you give an example where gksu doesn't work with a bash script? –  hexafraction Oct 12 '12 at 10:26
    
It's working. I was confused about running it in terminal. It won't work there, but in script it is good. Thanks @ObsessiveSSOℲ –  Anwar Shah Oct 12 '12 at 10:42
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.