Check file permission symbols
Run the command ls -l and you will the list of files and directories like below:
-rw-r--r-- 1 ambarish users 1201 Dec 12 13:10 info.txt
This basically represents that the file info.txt was created on Dec 12, at 13:10 and has a size of 1201 bytes. It belongs to the group "users" and is owned by the user "ambarish" in particular.
-rw-r--r--, drw-r--r-- basically represents the file permission.
1 - denotes the file type. a hyphen (-) denotes a regular file. "d" denotes a directory.
2,3,4 denotes read, write, execute permissions for the owner of file.
5,6,7 denotes read, write, execute permissions for members of group owning the file.
8,9,0 denoted read, write, execute permissions for all other users.
How to set permission of a file/directory
We can use chmod command in Linux to set permission of a file or a directory. They syntax is
chmod [permissions] [filename]
The permission can be assigned to any file or directory using the octal number system. 4 represents read access, 2 for write and 1 is for the access to execute.
So, if you want to assign a file read / write / execute access, it will be 4+2+1=7.
e.g. chmod 777 info.txt
7 = 4+2+1 - read, write, execute
6 = 4+2 - read write
5 = 4+1 - read execute
4 - read
3 = 2 + 1 write, execute
2 - write
1 - execute
Here's an infographic showing the file permissions in Linux/Unix.
Anything I missed? Please add it in the comments section.