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)
2 Answers
.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
- 174,437
-
1everything 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
-
1that means you are
not in the directory where the file you are trying to run resides. you need tocdinto it first, then run it again. – Peachy Jun 01 '13 at 02:02 -
Perhaps worth noting that running scripts via
sh script.shorbash script.shis somewhat of a gamble, since if you're running a script that is written with some ofbashno-portable features, doingsh script.shwill fail becauseshdoesn't have allbashfeatures.chmod +xis more sensible approach – Sergiy Kolodyazhnyy Dec 07 '17 at 08:34
To exectue a
.shfile,first you move to the directory which contains the.shfile from terminal.cd /path/to/the/directory/which/contains/filename.shthen run
lscommand to make sure that you are in correct directory(which contains.shfile).Run the below command to make the
.shfile asexecutablefile.sudo chmod 777 filename.shThen type the below command to
runthe.shfile,sudo ./filename.sh
- 9,296
- 80,616
-
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
-
1Please note, if script is located in user's home directory, especially if it's in downloads , there's no need to use
sudo. Also,777is 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 use755or700if you are the owner of the said script. – Sergiy Kolodyazhnyy Dec 07 '17 at 08:30 -
type cd
And then ./run.sh
– thefourtheye Apr 18 '13 at 04:10pwd– Chan Apr 18 '13 at 06:27