Ihave downloaded software for my Linux or Unix-like system from the Internet. There is a file called install.sh. How do I run an .sh file to install the software? How do your run .sh files from command line?
You can open or run .sh file in the terminal on Linux or Unix-like system. The .sh file is nothing but the shell script to install given application or to perform other tasks under Linux and 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.
How do I run .sh files in Linux?
The procedure to run the .sh file shell script on Linux is as follows:
- Set execute permission on your script:
chmod +x script-name-here.sh
- To run your script, enter:
The syntax is:
How to run .sh file as root user
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 the sudo or su command as follows:
sudo bash filename.sh
Type your password. Another option is to use the su command as follows to become superuser:
Type root user password and finally run your script:
How to use chmod command to run .sh shell script in Linux
Another recommend option is to set an executable permission using the chmod command as follows:
chmod +x file.sh
Now your can run your .sh file as follows
How do I run .sh file named install.sh?
Just run the following two command:
chmod +x install.sh
The dot (.) refers to the current working directory. The install.sh is in the current directory so you run it as above or as follows too:
GUI method to run .sh file
- Select the file using mouse.
- Right-click on the file.
- Choose Properties:
- Click Permissions tab.
- Select Allow executing file as a program:
- Now click the file name and you will be prompted. Select “Run in the terminal” and it will get executed in the terminal.