4

I tried changing the settings to /properties/permissions>allow executing as program. When I click on it, nothing happens? Any suggestions? I don't know if it makes a difference but it is a game (which I read somewhere shouldn't be ran in some specific way)

Tayler Wilson
  • 41
  • 1
  • 1
  • 3

2 Answers2

4

.sh file is nothing but the shell script to install given application or to perform other tasks under UNIX like operating systems. The easiest way to run .sh shell script in Linux or UNIX is to type the following commands. Open the terminal (your shell prompt) and type the command:

sh filename.sh

OR

bash filename.sh

Some time you need root access to install application; without root, you won't have the necessary permissions to install application or make system level modifications. Root access is disabled by default on many Linux and UNIX like systems. Simply use sudo or su as follows:

sudo bash filename.sh

Type your password. Another option is to use the su command as follows to become superuser:

su root

Type root user password and finally run your script:

bash filename.sh

Another recommend option is to set an executable permission using the chmod command as follows:

chmod +x filename.sh

Now your can run your .sh file as follows

./filename.sh
Radu Rădeanu
  • 166,822
  • 48
  • 327
  • 400
  • 1
    everything I try in that gives back what I typed plus "No such file or directory" which makes no sense because it is sitting in a folder on my desktop. – Tayler Wilson Apr 18 '13 at 04:57
  • 1
    that means you are `not in the directory where the file you are trying to run resides`. you need to `cd` into it first, then run it again. – Peachy Jun 01 '13 at 02:02
  • Perhaps worth noting that running scripts via `sh script.sh` or `bash script.sh` is somewhat of a gamble, since if you're running a script that is written with some of `bash` no-portable features, doing `sh script.sh` will fail because `sh` doesn't have all `bash` features. `chmod +x` is more sensible approach – Sergiy Kolodyazhnyy Dec 07 '17 at 08:34
4
  • To exectue a .sh file,first you move to the directory which contains the .sh file from terminal.

    cd /path/to/the/directory/which/contains/filename.sh
    
  • then run ls command to make sure that you are in correct directory(which contains .sh file).

  • Run the below command to make the .shfile as executable file.

    sudo chmod 777 filename.sh
    
  • Then type the below command to run the .sh file,

    sudo ./filename.sh 
    
ImaginaryRobots
  • 9,058
  • 4
  • 34
  • 38
Avinash Raj
  • 77,204
  • 56
  • 214
  • 254
  • and of course replace "filename.sh" with whatever the name of the actual file you are trying to run. – ImaginaryRobots Dec 10 '13 at 20:24
  • 1
    Please note, if script is located in user's home directory, especially if it's in downloads , there's no need to use `sudo`. Also, `777` is often undesirable as it gives everyone and anyone full permissions to read-write-execute the script ( and write permissions mean a malicious user can put something undesirable in the script). More sensible approach is to use `755` or `700` if you are the owner of the said script. – Sergiy Kolodyazhnyy Dec 07 '17 at 08:30
  • **sudo chmod 777 filename.sh** Thanks , commands works in my case – Syed Zain Ali Dec 28 '18 at 14:50