1. How to identify is file or directory?
2. Read permissions.
3. Change file/directory permissions.
In Linux file permissions are very important. Every directory and file has permissions for owner, groups and others. Now I will let you know, who are the owner, groups assigned and other.
- User (Owner) – By defaults, a user who creates the file or directory known as the owner.
- Group – I will explain this with the example. Assume you are the member of IT team of 8 people and your manager wants to share a file or directory with IT team then he will not share this individually with everyone. Instead of that, he will make one group with name IT and assign a group to that file or directory. By default, a user who creates file or directory, that user becomes the group of that file.
- Other – The person who neither created a file or even not a member of the group but needs to access the file. Then Other permissions play an important role.
How to find which one is a directory or which one is a file?
d: for directory
– : for file
Example: see the picture, first 3 rwx permission for owner, next 3 for the
r = read, w = write , x = execute.
How To read permissions of file/directory ?
- I will show you simplest method to read the permissions of file or directory with the example. To assign permissions, we will use the numeric method here. In this method always remember this :
r = 4
w = 2
x = 1
– = 0
Change directory/file permission
Here I am assuming a user is the
[arun@localhost ~]$ chmod 770 centos/
Assign permissions recursively to sub- folders
Use -R to assign permission on subfolders. Note in Linux, capital and small alphabets have significant meaning. In this example, 770 permission would be assigned to subfolders under “centos” directory.
[arun@localhost ~]$ chmod -R 770 centos/
By default permissions (Remember these for an Interview purposes):
1. When root user creates, directory = 755 and file = 644
2. normal user creates, directory = 775 and file = 664
3. /home/user = 700
4. /root = 550
5. /tmp = 777
Perfect !!! You have learned about file permissions