Script File Permissions

Imran Afzal (250k+ students)
A free video tutorial from Imran Afzal (250k+ students)
Bestselling Instructor with over 250,000 students worldwide
4.6 instructor rating • 16 courses • 248,071 students

Learn more from the full course

Complete Linux Bash Shell Scripting with Real Life Examples

Shell Scripting and Programming to Automate your Daily Tedious Tasks

14:34:55 of on-demand video • Updated December 2020

  • Students will be able to understand shell scripting concepts
  • Students will be able to write basic to advance level shell scripts
  • Students will understand how shell scripts become useful to automate daily system administration tasks
  • How to accept input from a user and then make decisions on that input
English [Auto] Script file permissions. Now this is not just theoretical or concept or standard that I am trying to explain it to you. This is actually mandatory. You need to have the right permission to execute a script and to and to have a proper permissions on the script file itself. So all scripts to be executed should have a proper executable file permissions and those are. For example if you see here it's read write an X is for executable meaning the root. The person who created this group can execute it then read dash X meaning the group who belongs to that user or user belongs to a group has a right to read and execute their script. And the last one or the other people who do not belong to your group or they are not you. They could also execute that script and read it. But of course they cannot write it because you don't see that W and W in the middle of group and others. So every time you create a script you need to assign the executable permission. OK so now you're probably thinking Hey when I create this group why can't it get assigned by default executable permission. Good question. But the problem is that whenever you create a script in Linux or whenever you create a file I should say nix by default. It does not assign executable permissions because it doesn't want you to make a mistake and executed something by mistake and corrupt your file system. That's why it doesn't give the executable permissions you have to sign them yourself. Ok now I created a script. Now how do you change the permissions. Simply the command to change the permission is S.H. moderate a plus X and the name of the script. A stands for all. Everybody should have executable permission off the script I use. I prefer letters as a or G or O for Jews group and others. There are other people or you probably are familiar with the digits as well like 6 5 5 6 7 something like that which I am not too much familiar. I try to follow something that I am very familiar with and I would like to teach you something that I know. Anyway if you are comfortable with your own way of saying permission be my guest. You feel free to use that. Now let's see if I log into my machine and I create a script. Then how can we change permission. So let's see where is my Linux machine my Linux machine is right here and I am in my slash homes. I have sawle slash script directory. I wanted to create a script and there are few ways you could create a file. First you always create a file. You could touch it via it and you could execute an output to a file. The different ways whichever way you want to start creating a script. So first thing I would use a very basic is touch and the name of the script lets say script name as a Pacitti script. Enter now when I do ls minus l tr you'll notice the script that I had before hello world has the executable permission right. This is the third bit you see here. The new script that I created which is a pacis script does not have the executable permission. So in order for you to run that script you need to assign executable permission to assign the permission you have to run the command change model. As I said I'll use for all. Everybody should have executable plus X for executable. The name of the script. Hit enter. Now do this by necessity or you will see the name of the script and its correct permission. That is how you assign permission. Very easy to do that if you are already in the next you've been using Linux. You probably like how I know that. Perfect. If you know that. Let's move on.