How To Change Permissions In Linux?
Share
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
1. Change Permissions Using the chmod Command
The chmod command is used to change the permissions of a file or directory. To use it, you specify the particular permissions you want, plus the file or directory you want to modify.
For example, the following command grants read, write, and execute permissions to the user, read and execute permissions to the group, and no permissions to others for the file test.txt:
chmod u=rwx,g=rx,o= test.txt
2. Change Permissions Using the chown Command
Another way to change file permissions is with the chown command. This command allows you to change the owner and group of a file or directory.
For example, the following command changes the owner of the file test.txt to the user john and the group to the group admins:
chown john:admins test.txt
3. Change Permissions Using the setfacl Command
The setfacl command is used to set file access control lists (ACLs) on files and directories. This command allows you to set more fine-grained permissions than the chmod and chown commands.
For example, the following command grants read and execute permissions to the user john and read permissions to the group admins for the file test.txt:
setfacl -m u:john:rx,g:admins:r test.txt