Aug 19, 2021

[Linux] provide permissions to file or directory

To provide permissions to file or directory, we can use "chmod" command.

To give all users all permissions to all txt files, 

        chmod  777  *.txt


We can create file or folder with permission setting:

    for a folder,    mkdir  -m777  folder_name  

    for a file,    chmod  -m777  file_name.txt  >>  file_name.txt  


List of numerical shorthand:

0:  (000)  no permission

1:  (001)  execute permission

2:  (010)  write permission

3:  (011)  write and execute permission

4:  (100)  read permission

5:  (101)  read and execute permission

6:  (110)  read and write permission

7:  (111)  read, write and execute permission

e.g., 777 means read, write and execute permission to user, group, and other user


- rw- rw- r--  

the first "-" means file (d for directory, e.g.,  d rw- rw- r--  )

the next three sets of three characters are for user permission, group permission, and other permission, respectively.


No comments:

Post a Comment