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.

Let's say I have a downloadable text file on my website that says

sudo apt-getupdate

How can I make it so that the user downloads it and it auto puts that code into terminal? What would I do for something that has many lines of code?

share|improve this question

2 Answers 2

up vote 3 down vote accepted

If you put this line:


at the beginning of the text file, Ubuntu will know than is an executable file to be interpreted by bash. So your file would look something like this:

sudo apt-get update

When the user double clicks the file, she/he will be asked if wants the executable to be run in a terminal.

share|improve this answer
This wont work all this time. First, the file has to be set to executable, then the appropriate setting needs to be set in Files -> Preferences -> Behaviour -> Executable Text Files. –  minerz029 Jan 2 '14 at 23:26
Yes, I was asuming that behaviour, but you're right. I've upvoted your answer, thanks! –  darent Jan 2 '14 at 23:28
Thanks a ton! This is a good solution. –  Mike Wentworth Jan 3 '14 at 0:27

You can simply give your user these commands:

wget -O- http://example.com/script.sh | bash -

You will need to replace bash with the program which should execute your script.

The first method will not save the file on disk. It will only be downloaded and directly executed. If the file should be saved, you can use the following:

wget http://example.com/script.sh
chmod +x script.sh

The file will be kept as script.sh in the current directory. This requires a shebang line at the top of the file.

share|improve this answer

Your Answer


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.