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.

Possible Duplicate:
How do I run .sh files in Terminal?

I want to download JDownloader from the internet for Linux. But the file is .sh and when I tell ubuntu to open the file it uses some text editor. I searched Ubuntu Software Store and there was no application to open it. Is there any way I can get it installed?

share|improve this question

marked as duplicate by Eliah Kagan, jokerdino, Mitch, devav2, Tom Brossman Oct 7 '12 at 11:44

This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.

4 Answers 4

up vote 52 down vote accepted
  1. copy the file to the desktop (for convenience)

  2. Right click on the file and select properties enter image description here

  3. Under permission tab check allow executing file as program enter image description here

  4. double click on the file and chose run in terminal if it is not a gui program) enter image description here

Command line

cd /path/to/file
chmod +x filename.sh
./filename.sh

Comment below if it wont work :)

If it still won't work, despite having allow executing file as a program ticked, when you double click on the .sh file, and it launches gedit, navigate to the folder with the script.

Once you are in the correct current folder for the script, you can run the script like this:

sudo ./filename.sh

From FAT partition

Follow this How do I execute a file from a FAT USB drive?

share|improve this answer
2  
Typically though, .sh files do need to be run in the terminal. –  Thomas W. Jul 14 '12 at 13:14
    
command line work but how can I run it with a double click? doesn't show the option "open with terminal" –  dodohjk Apr 21 '13 at 13:02
7  
@dodohjk, (in Ubuntu 13.04) there is an option that controls this - File > PReferences > Behavior > Executable Text Files –  aldrin May 3 '13 at 7:13
    
Just an FYI, I had to copy my file to another directory before this worked. –  Cody Sep 24 at 20:06
1  
@Cody : That is because your USB drive is in either NTFS or FAT format . They do not support Linux permissions :-) –  Tachyons Sep 26 at 6:24

Command line

Apart from what liquid had recommended, usual procedure is to change permissions to make this file executable:

chmod +x file.sh

And then execute this file:

./file.sh

GUI

The same can be achieved in Nautilus file browser using context menu by changing Execute flags in Properties -> Permissions.

share|improve this answer

Try sh nameoffile.sh in terminal (making sure you are in the folder where nameoffile.sh is saved)

share|improve this answer

You can also use . tricks, with the suggestion of other answers.

For example:

chmod +x filename.sh, assuming you have already gone to the path to file then run the file with any one of these command:

sh filename.sh

./filename.sh

. filename.sh

share|improve this answer
    
The last one, . might not be what you want, since the variables and functions from the script will remain in your current shell. –  domen Feb 21 '13 at 16:41

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