Basic list views of file and their permissions
The command we use is ls -l to show us the list of files/directory in the current folder we are present. This screenshot is a common example to show permission (using normal centos7 )
From the above screenshot, let’s take a file let’s say luser_t04.sh, and see its file permissions
-rwx rwx rwx 1 root root 0 Feb 27 17:35 luser_t04.sh
1 2 3
(r = read , w= write , x = execute)
- 1 represents the permission of the user, they have all the 3 permission to read, write and execute the file
- 2 represents the group to which the file is associated it also has all the permissions
- 3 represent others which also contains all the 3 permissions
Bash Script – File Permissions
In this article, we will discuss file permission in Bash Script
To understand the scenario let’s take an example. Let’s consider there is a system admin A for company XYZ he designs a script that is to be executed by a user at 8:00 PM daily to send a report. He designs the script but forgets to give permission to the user to execute the script. Whenever a user tries to execute a script, he gets the error You are not authorized to take this action so why did this happen?
In the above case, we see that the system admin created a script but he did not give permission to the user as he was unable to execute it so to go into depth about this let’s explain how can we set file permission and how to check them.
Solution: Now for the above example the system admin only has to give or set the user file permission to execute so that he can execute that file