Article Title: File Permission management-POSIXACL. Linux is a technology channel of the IT lab in China. Includes basic categories such as desktop applications, Linux system management, kernel research, embedded systems, and open source.
In Unix/Linux systems, the permission mechanism has been used for many years. Due to lack of flexibility, it is far behind and not suitable for applications in today's information systems. However, a new permission mechanism standard has been developed. This article will introduce the operating methods of this new mechanism on Linux.
Traditionally, in Linux, each file and directory has a permission (permission) to determine who can use the file.
Permissions are divided into three groups: file owner, group, and others ). Each group has its own attributes. There are also three types of attributes: read, write, and executable ).
We can use "ls-l" to view the file permissions:
-Rwxrw-r -- 1 adam mis 272401 May 10 2003 report.doc
In the preceding example, the owner of the file report.doc is "adam", and adam can read, write, and execute this file. In addition, the group of report.doc is "mis ", in the system, all users in the mis group can read and write this file, while other users can only read this file.
If we want the report.doc content to be read only to users in the mis group, we can use the "chmod 640 report.doc" command to change its permissions.
-Rw-r ----- 1 adam mis 272401 May 10 2003 report.doc
If the file report.doc is to be read to users in both mis and hr groups, the existing permission mechanism cannot be easily set. The system administrator needs to add a new group (I. e. mishr) for us and add all users of mis and hr to the mishr group. Then we will use "chgrp mishr report.doc" to set the group to mishr.
-Rw-r ----- 1 adam mishr 272401 May 10 2003 report.doc
If our requirements are more complex: to enable users to read and write data to adam and eva, group mis and hr can only read data. Therefore, we cannot get such permission settings for any new group. To get the above permission settings, we need a new permission mechanism. This mechanism is called the Access Control List (ACL ). ACL is an extension of the existing permission mechanism. In addition to the three basic settings (owner, group, and others), we are allowed to add access permission settings for a specified user or group.
To address inherent limitations of Unix systems, a posix acl permission mechanism standard was developed. The purpose is to develop a compatible ACL standard for each Unix system so that each user can use a unified interface between each system.
This posix acl function is officially supported on Linux kernel 2.6, and then back-port to 2.4 kernel. ACL can be used in common file systems, such as ext3, xfs, jfs, and ReiserFS. Of course, you need to start the ACL when compiling the kernel.
Related kernel option:
CONFIG_FS_POSIX_ACL
CONFIG_EXT3_FS_POSIX_ACL
CONFIG_EXT2_FS_POSIX_ACL
Mount File System
Although posix acl support has been added to the kernel, It is not automatically enabled. You must specify the ACL when mounting the file system. For example:
Mount-t ext3-o acl/dev/sda1/home
-O acl is the option to enable ACL on/dev/sda1.
You can also add the following options to/etc/fstab:
/Dev/sda1/home ext3 acl 1 2
View ACL
To view the ACL of a file or directory, use the "getfacl" command:
[Adam @ www adam] $ getfacl report.doc
# File: report.doc
# Owner: adam
# Group: mis
User: rwgroup ::
Rwother ::
R --
The preceding example lists a basic ACL (Minimum ACL ). The first three behavior archives include the owner and group of the archives. Each rule in the ACL is followed.
In this basic ACL:
User: rw-owner adam can read and write data
Group: rw-users in the mis group can read and write data.
Other: r -- other users can only read
[1] [2] Next page