In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-01-27 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Servers >
Share
Shulou(Shulou.com)06/01 Report--
This article mainly explains "how to give users read and write access to a specified directory on Linux". Interested friends may wish to have a look at it. The method introduced in this paper is simple, fast and practical. Let's let the editor take you to learn how to give users read and write access to a specified directory on Linux.
In this article, we will show you how to give users read and write access to a specified directory on Linux.
There are two ways to achieve this: * use ACL (access control list), and the second is to create user groups to manage file permissions, which are described below.
To complete this tutorial, we will use the following settings.
Operating system: CentOS7
Test directory: / shares/project1/reports
Test user: tecmint
File system type: ext4
Make sure that all commands are executed using the root user, or use the sudo command to enjoy the same permissions.
Let's get started! Next, use the mkdir command to create a directory called reports.
# mkdir-p/shares/project1/reports
Use ACL to give users read and write permissions to directories
Important: if you plan to use this method, you need to make sure that your Linux file system types, such as ext3 and ext4,NTFS,BTRFS, support ACL.
1. First, check the current file system type on your system and see if the kernel supports ACL according to the following command:
# df-T | awk' {print$1,$2,$NF}'| grep "^ / dev" # grep-iacl/boot/config*
As you can see from the screenshot below, the file system type is ext4, and from the CONFIG_EXT4_FS_POSIX_ACL=y option, you can see that the kernel supports POSIXACL.
2. Next, check whether the ACL option is used when mounting the file system (partition).
# tune2fs-l/dev/sda1 | grepacl
From the output above, you can see that ACL is already supported in the default mount project. If you find that the result is not what you want, you can turn on ACL support for the specified partition (/ dev/sda3 in this case) with the following command.
# mount-oremount,acl/ # tune2fs-oacl/dev/sda3
3. Now is the time to assign read and write permissions to the directory reports to the user named tecmint. Follow the command below.
# getfacl/shares/project1/reports#CheckthedefaultACLsettingsforthedirectory # setfacl-muser:tecmint:rw/shares/project1/reports#Giverwaccesstousertecmint # getfacl/shares/project1/reports#ChecknewACLsettingsforthedirectory
In the screenshot above, you can find that the user tecmint has been successfully granted read and write permissions to the / shares/project1/reports directory by the second line of the getfacl command that outputs the result.
Let's take a look at how to use the second method to give read and write permissions to directories.
Use user groups to give users read and write access to a specified directory
1. If the user already has a default user group (usually the group name is the same as the user name), you can simply change the user group of the folder.
# chgrptecmint/shares/project1/reports
In addition, we can also create a new user group for multiple users (those who need to be given read and write permissions to the specified directory) in the following ways. In this way, a shared directory is created.
# groupaddprojects
2. Next, add user tecmint to the projects group:
# usermod-aGprojectstecmint # addusertoprojects
# groupstecmint # checkusersgroups
3. Change the user group of the directory to projects:
# chgrpprojects/shares/project1/reports
4. Now, set read and write permissions for group members.
# chmod-R0760/shares/projects/reports # ls-l/shares/projects/ # checknewpermissions so far, I believe you have a better understanding of "how to give users read and write access to a specified directory on Linux". You might as well do it in practice. Here is the website, more related content can enter the relevant channels to inquire, follow us, continue to learn!
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.