|
In the Linux system, you can create a file or subdirectory to achieve the directory, and inherit permissions from the parent directory by setfacl.
The following root ordinary users user1. In the directory / mnt under
[Root @ RedHat-7 mnt] # setfacl -m u: user1: rwx share // directory Add ower = user1, and given the right to the root of rwx.
[Root @ redhat-7 mnt] # setfacl -d -m u: user1: rwx share // add default acl permissions directory, create directories and files in this directory will inherit the rights information
[Root @ redhat-7 mnt] #
[Root @ redhat-7 mnt] #
[Root @ redhat-7 mnt] # getfacl share // Check facl share the information
# File: share
# Owner: root
# Group: root
user :: rwx
user: user1: rwx // user1 at this time in order to have write access to the share
group :: r-x
mask :: rwx
other :: r-x
default: user :: rwx // default permissions subdirectory or file information
default: user: user1: rwx
default: group :: r-x
default: mask :: rwx
default: other :: r-x
[Root @ redhat-7 mnt] # cd share /
[Root @ redhat-7 share] # ls
[Root @ redhat-7 share] # touch roota
[Root @ redhat-7 share] # touch rootb
[Root @ redhat-7 share] # mkdir rootdir1
[Root @ redhat-7 share] # mkdir rootdir2
[Root @ redhat-7 share] # ls
roota rootb rootdir1 rootdir2
[Root @ redhat-7 share] # getfacl roota
# File: roota
# Owner: root
# Group: root
user :: rw-
user: user1: rwx #effective: rw-
group :: r-x #effective: r--
mask :: rw-
other :: r--
[Root @ redhat-7 share] # getfacl rootdira
getfacl: rootdira: No such file or directory
[Root @ redhat-7 share] # getfacl rootdir
rootdir1 / rootdir2 /
[Root @ redhat-7 share] # getfacl rootdir1
# File: rootdir1
# Owner: root
# Group: root
user :: rwx
user: user1: rwx
group :: r-x
mask :: rwx
other :: r-x
default: user :: rwx
default: user: user1: rwx
default: group :: r-x
default: mask :: rwx
default: other :: r-x
[Root @ redhat-7 share] #
Now enter the directory with user1 detected permissions:
[User1 @ redhat-7 share] $
[User1 @ redhat-7 share] $
[User1 @ redhat-7 share] $
[User1 @ redhat-7 share] $ ll
total 8
-rw-rw-r - + 1 root root 0 Nov 19 22:52 roota
-rw-rw-r - + 1 root root 0 Nov 19 22:52 rootb
drwxrwxr-x + 2 root root 6 Nov 19 22:52 rootdir1
drwxrwxr-x + 2 root root 6 Nov 19 22:52 rootdir2
[User1 @ redhat-7 share] $ touch user1a
[User1 @ redhat-7 share] $ touch user1dir1
[User1 @ redhat-7 share] $ getfacl user1a // Check new file permissions
# File: user1a
# Owner: user1
# Group: user1
user :: rw-
user: user1: rwx #effective: rw-
group :: r-x #effective: r--
mask :: rw-
other :: r--
[User1 @ redhat-7 share] $ rm roota // try to delete files created by root, success
[User1 @ redhat-7 share] $ rm rootdir1 // try to delete the root directory was created successfully
rm: can not remove arootdir1a: Is a directory
[User1 @ redhat-7 share] $ rm rootdir1 -r
[User1 @ redhat-7 share] $ ll
total 4
-rw-rw-r - + 1 root root 0 Nov 19 22:52 rootb
drwxrwxr-x + 2 root root 6 Nov 19 22:52 rootdir2
-rw-rw-r - + 1 user1 user1 0 Nov 19 22:57 user1a
-rw-rw-r - + 1 user1 user1 0 Nov 19 22:57 user1dir1
[User1 @ redhat-7 share] $
So, when there is a demand to do the right root of inheritance, you can use the party to achieve.
In the new rhel7, there will be new tools chacl similar setfacl. |
|
|
|