From the course: Linux Bash Shells and Scripts: Streamlining Tasks and Enhancing Workflows with Automation

Unlock this course with a free trial

Join today to access over 24,900 courses taught by industry experts.

Setting the script interpreter and permissions

Setting the script interpreter and permissions

- [Instructor] Let's jump in to Bash shell scripts, also known as shell programs. So first of all, the first two characters in the file often should be hash or pound sign, exclamation point, and that little combination of two characters is sometimes called the shebang. And after the shebang should be the path to the program to interpret the file. And since it's a Bash script, it's usually the path to the Bash program, which typically is bin/bash, /bin/bash. And if for example, you change your path and Bash is some weird place or something, if you want to have the shell find the Bash path that you want it to use, then you could usr/bin/env and bash and then that would find the path to Bash. But that's very unusual for Bash, so bin/bash is typical. If you don't say that then you might not know what shell is going to interpret the program, so that's not a good idea. Use the #!/bin/bash. So what happens when you run a program, a shell script or a compiled C program is the kernel has to…

Contents