Tuesday, February 22, 2011

Run .SH scripts in Ubuntu

Files with a .SH extension are little scripts that can be used to perform a set of given tasks without typing them in the terminal again and again. For example, you can get a script to automatically install the 64-bit Flash Player on Ubuntu at this site.

But when you attempt to open such a file, it just opens it up in Gedit. Here's how to run it.

For this walkthrough, I will assume that you have a file called 'sample.sh' in your Downloads folder. If you are a total beginner, you can rename your script to this name, put it in your /home/Downloads folder and copy the exact commands that I show here.
  • Open up a Terminal first. You will find it it Applications, Accessories.
  • Change your directory to your Downloads folder by typing the command:
cd ~/Downloads [The ~ sign stands for your Home directory]
  •  Now your Terminal should look like so:

  •  To run the sample.sh file in that directory, simply type its name, preceded by 'sh', like so:
sh sample.sh
 Now your script should run, and it should do whatever it is supposed to do.


Share/Bookmark