Linux : Special permissions to users for file & directories using "setfacl"
To set special permissions to users for files and directories using the "setfacl" command in Linux, you can follow these steps:
Install the "acl" package if it is not already installed on your system. You can do this using your distribution's package manager, such as apt, yum, or pacman. For example, on Ubuntu or Debian, you can run the following command:
sudo apt-get install acl
Check the current ACL settings of the file or directory you want to modify by using the "getfacl" command. For example, to check the ACL settings of a file called "example.txt", you can run the following command:
getfacl example.txt
This will show you the current permissions and access control entries (ACEs) for the file.
Use the "setfacl" command to add or modify the ACEs for the file or directory. The basic syntax of the "setfacl" command is as follows:
rubysetfacl -m user:<username>:<permissions> <file/directory>
In this command, you need to replace <username> with the username of the user you want to set permissions for, and <permissions> with the special permissions you want to grant. You can use any of the following special permissions:
- r: read
- w: write
- x: execute
- d: delete
- a: append
For example, to grant the user "krishna" read and write access to the file "example.txt", you can run the following command:
sqlsetfacl -m user:krishna:rw example.txt
You can also use the "-R" option to apply the ACEs recursively to all files and directories within a directory. For example, to grant the user "krishna" read and write access to a directory called "mydir" and all its contents, you can run the following command:
sqlsetfacl -R -m user:krishna:rw mydir
Verify the ACL settings using the "getfacl" command again. For example, to check the ACL settings of the file "example.txt" after setting the ACE for "krishna", you can run the following command:
getfacl example.txt
This should show you the updated ACEs for the file.
That's it! You have now set special permissions to users for files and directories using the "setfacl" command in Linux.
Comments
Post a Comment