How to make shell script file executable in Ubuntu | How do I makea a .sh file executable in linux
What is shell script ?
Before starting shell script at first we should know about this programming language. Shell script is a program which is run on linux operating system which is called Unix shell. It is used to write programs to print text, file manipulation, repeatative task can be done by this script. When we create any shell script file in our linux system, we have to run it . How shell file actually runs?. There can be multiple ways to run shell script file, but we will discuss here only three types.
Make .sh file executable using "source" command$ source filename.sh
using source command we can run it directly on our system from anywhere.
Make .sh file executable using "Allow permission"
In this option we will create first .sh file. we will right click on it and check the user permission on the file. Now we will give permission to this script file and then we can run it simple.$ ./filename.sh
Make .sh file executable using "change mode of chmod"
In this option we will create first .sh file. we need to change the mode ch mode.$sudo chmod 777 filename.sh