What is .sh file in Ubuntu and how to run .sh file in Ubuntu. Terminal commands to run a shell file in Ubuntu. Executing a .sh file in Ubuntu is pretty easy. Let us see how.
.sh file is a shell script. A shell script is a text file that contains a sequence of commands for a UNIX/Debian/Linux/Ubuntu-based system. A shell script file contains “script”, a sequence of commands which have a repeated use.
.sh files are Unix (Linux) shell executables files, they are the equivalent (but much more powerful) of bat files on windows. So you need to run it from a Linux console, just typing its name the same you do with bat files on windows. and that means that it uses Bourne Again Shell, so called bash.
How To Run .sh File In Ubuntu Linux
Executing a .sh file in Ubuntu is pretty easy. If you have a .sh file, follow the steps given below to run .sh shell script file in Ubuntu.
Before running .sh file, you will have to give proper permission to the script. Run the following commands in Terminal:
chmod +x /path/to/yourscript.sh
Once the proper permission is granted, run the .sh script using the command below:
/path/to/yourscript.sh
If the script file is in the current directory, simply use ./yourscript.sh command. In the following command . refers to the current directory. Which means to run a .sh file in the current directory, simply run the command:
./yourscript.sh
Alternative Method
You can also enable the .sh file to execute as a program. To make a shell script file executable:
- Right-click on the file
- Select Properties
- Select Permissions
- Select Allow executing file as a program
Once done, simply double-click on the shell file and click run in terminal option.