Ubuntu: When I try to run .sh files nothing happens?



Question:

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)


Solution:1

  • 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   


Solution:2

.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  

Note:If u also have question or solution just comment us below or mail us on toontricks1994@gmail.com
Previous
Next Post »