Have you ever wondered what wouldn't be great if you created a file, worked on it and allowed a selected to have access to it? You would say, it's possible if we create a group and add those users to a group. But if I say there's no need to create a group you can do it directly through the ACL
command. Today in this blog I am going to show you how you can do this very easily !
First, you need to install
ACL
on your Linux system.Now we are going to use the
getfacl
andsetfacl
commands.With the
gatfacl
command, you can view the permissions of a particular file or directory systematically.Now let's use the
setfacl
command.First of all, we have to create a directory. new
Redirect yourself to the
usr
directory. Now create a new directory, I would name ittmpops
. Enter into the directory and create a filehello.txt
Now first of all when you created a directory, you had to use
sudo
permissions to do that. So first change the group user and the owner of the.txt
file to your default user for me. By default, the user isubuntu
.Now to give your user privileged access we are going to use
setfacl
command.#Set specific user or group permissions on a file or directory: setfacl -m u:user_name:permissions /path/to/file_or_directory setfacl -m g:group_name:permissions /path/to/file_or_directory #Remove a specific user or group entry from the ACL: setfacl -x u:user_name /path/to/file_or_directory setfacl -x g:group_name /path/to/file_or_directory #Remove all extended ACL entries for a file or directory: setfacl -b /path/to/file_or_directory
Now switch to your user for me its user2.
You can see, I gave my user the read privilege and it can easily read the hello file but it cannot edit it Now, if I switch as some other user and try to read or access the file, I will not be able to do it.
This is how you can bring ACL commands into action.
Thanks for giving your time ❤️❤️