您的位置:首页 > 运维架构 > Shell

《Linux命令、编辑器与Shell编程》读书笔记5-用户和文件权限管理

2015-12-06 20:40 609 查看

一、用户管理

【系统用户文件】

#系统用户文件/etc/passwd,主要保存用户及用户设置

# tr -s":" "\t\t" < passwd | grep root
root x 0 0 root /root /bin/bash
... ...
第一列:用户名
第二列:用户登录密码,x表示密码被保存在/etc/shadow中
第三列:用户ID(即UID);UID从0~499都是系统保留给系统用户使用的;因此,自建用户的UID都是从500开始
第四列:用户组ID(即GID)
第五列:可选字段,一般为空,通常用来保存一些用户全名之类的附加信息
第六列:该用户的家目录
第七列:保存用户当前使用的Shell种类

#用户密码文件/etc/shadow,保存密码、登录相关配置信息(分隔符为:)

# catshadow
at:*:16564:0:99999:7:::
bin:*:15870::::::
daemon:*:15870::::::
ftp:*:15870::::::
root:$1$FOc$mPk/6NkY5FlHDeZ7tq6F/0:15870::::::
... ...
第一列:用户名
第二列:加密后的用户密码,如果以$1$开头,表示采用MD5不可逆加密
第三列:最后一次修改密码的距今天的天数(从未修改过的话、则默认从1970年1月1日算起)
第四列:两次修改密码的间隔天数,在此期间、用户不能随意修改密码(0则表示可以随时修改)
第五列:密码最长保留天数,1表示不能修改密码
第六列:密码过期前的警告天数,-1表示没有警告
第七列:密码过期后、禁止用户登录的天数,1表示不会被禁用,以自1970年1月1日以来的天数表示
第八列:保留字段,一般都为空

*注:上述两个文件不要直接使用编辑命令直接修改

【用户管理】

用户组基本概念及相关配置文件

Linux和Windows类似,也可以通过新增用户组实现权限集中管理。但稍有不同,linux在创建每个用户时,会自动创建和新用户同名的一个用户组(称为私有组)、并自动将这个用户加入到这个私有组里,同时,如果不指定新建用户的非私有组,则linux会把它加入到默认的users用户组下面,如下:
# ll
drwx------ 25 xk users 4096 Dec 5 06:21 xk

系统用户组文件/etc/group,内容如下

# cat/etc/group
root:x:0:
bin:x:1:daemon
… …
daemon:x:2:
sys:x:3:
dba:!:1003:oracle
oinstall:!:1004:
第一列:用户组名称
第二列:组密码,为空表示不需要密码;x表示密码存在/etc/gshadow
*在我搭建的虚拟机上没有找到/etc/gshadow这个文件,而是直接把组密码写到了上面的文件里
第三列:组ID,即GID
第四列:该组包含的用户列表,多个用户之间用逗号分隔

用户组密码文件/etc/gshadow

传统存放编码后的群组密码,但这个文件目前已经不被系统支持,所以如果建立群组密码,还是会被直接放在/etc/group 的密码列。
*在我搭建的虚拟机上没有找到/etc/gshadow这个文件,有待确认

添加用户组groupadd

【命令格式】

groupadd[option] groupname

【OPTION】

-g,--gid gid
Force the new group ID to be the givennumber. This value must be positive and unique. The default is to use the firstfree ID after the greatest used one. The range from which the group ID ischosen can be specified in /etc/login.defs.

--preferred-gidgid
Set the new group ID to the specifiedvalue if possible. If that value is already in use the first free ID will bechosen as described above.

-o,--non-unique
Allow duplicate (non-unique) group IDs.

-p,--password password
Encrypted password as returned bycrypt(3) for the new account. The default is to disable the account.

-r,--system
Create a system group. A system groupis an entry with an GID between SYSTEM_GID_MIN and SYSTEM_GID_MAX as defined in/etc/login.defs, if no GID is specified.

--serviceservice
Add the group to a special directory.The default is files, but ldap is also valid.

-D,--binddn binddn
Use the Distinguished Name binddn tobind to the LDAP directory. The user will be prompted for a password for simpleauthentication.

-P,--path path
The group file is located below thespecified directory path. groupadd will use this files, not /etc/group.

--helpPrint a list of valid options with a short description.

--usage
Print a short list of valid options.

-v,--version
Print the version number and exit.

【涉及的系统文件】

/etc/group- group account information

删除用户组groupdel

【命令格式】

groupadd[-D binddn] [-g gid [-o]] [-r] [-P path] [-p password]
groupname

【OPTION】

--serviceservice
Add the account to a special directory.The default is files, but ldap is also valid.

-D,--binddn binddn
Use the Distinguished Name binddn tobind to the LDAP directory. The user will be prompted for a password for simpleauthentication.

-P,--path path
The passwd and shadow files are locatedbelow the specified directory path.chpasswdwill use this files, not /etc/passwd and /etc/shadow.

--helpPrint a list of valid options with a short description.

-u,--usage
Print a short list of valid options.

-v,--version
Print the version number and exit.

【涉及的系统文件】

/etc/group- group account information

添加用户useradd

该命令位于/usr/sbin/下面,有些OS会给useradd加一个软链接命名为adduser,因为老些的操作系统这么命名。

【命令格式】

useradd[option] username

【OPTION】

-c,--comment comment
用户的一些描述信息,存放在/etc/passwd的第五列

-d,--home homedir
指定新用户的家目录,如果不指定
12de3
,则根据/etc/default/useradd中的HOME变量进行分配,一般和下面的m参数配合使用

-m,--create-home
为新用户创建家目录,和上面的参数d配合使用.

-e,--expire expire
With this option the date when the account will be expired can bechanged. expiredate has to be specified as number of days since January 1st, 1970.The date may also be expressed in the format YYYY-MM-DD. If not specified, thedefault from /etc/default/useradd
is used.

-f,--inactive inactive
This option is used to set the number of days of inactivity after apassword has expired before the account is locked. A user whose account islocked must contact the system administrator before being able to use theaccount again. A value of
-1 disablesthisfeature. If not specified, thedefault from /etc/default/useradd is used.

-G,--groups group,...
指定新用户的用户组(supplementary groups),可以属于多个组,每个组名用逗号隔开. 如果不指定,默认根据/etc/default/useradd中的GROUP(值为组ID)变量进行分配

-g,--gid gid
新用户所属的主用户组(main group)。如果不指定,默认根据/etc/default/useradd中的GROUP(值为组ID)变量进行分配。
*这里注意下-g和-G的区别:如果用id命令查看某个用户的话:
# id oracle
uid=1003(oracle)gid=1004(oinstall) groups=1003(dba),1004(oinstall)
-g对应的是里面的gid,-G对应的是里面的groups值

-k,--skel skeldir
指定从哪个目录向新用户家目录复制模板文件,默认从/etc/default/useradd中读取.

-o,--non-unique
Allow duplicate (non-unique) User IDs.

-p,--password password
Encrypted password as returned by crypt(3) for the new account. Thedefault is to disable the account.

-U,--umask umask
The permission mask is initialized to this value. It is used byuseradd for creating new home directories. The default is taken from/etc/default/useradd.

-u, --uiduid
Force the new userid to be the given number. This value must bepositive and unique. The default is to use the first free ID after the greatestused one. The range from which the user ID is chosen can be specified in/etc/login.defs.

--preferred-uiduid
Set the new userid to the specified value if possible. If that valueis already in use the first free ID will be chosen as described above.

-r,--system
Create a system account. A system account is an user with an UIDbetween SYSTEM_UID_MIN and SYSTEM_UID_MAX as defined in /etc/login.defs, if noUID is specified. The GROUPS entry in /etc/default/useradd is ignored, too.

-s,--shell shell
指定用户登录后使用的默认shell. 默认是从/etc/default/useradd中的SHELL取值, 如果设为/bin/false则表示不允许该用户通过终端登录.

--serviceservice
Add the account to a special directory. The default is files, butldap is also valid.

-D,--binddn binddn
Use the Distinguished Name binddn to bind to the LDAPdirectory. The user will be prompted fora password for simple authentication.

-P,--path path
自定义新用户passwd和shadow文件的存放位置,而不把该用户的基本信息存放到/etc/passwd and /etc/shadow.

--helpPrint a list of valid options with a short description.

--usage
Print a short list of valid options.

-v,--version
Print the version number and exit.

【涉及的系统文件】

1. /etc/group- group information
2. /etc/default/useradd– 为useradd命令提供默认值
GROUP=100 注:gid=100,表示可创建普通组

HOME=/home 注:把用户的家目录建在/home中;用户家目录的默认创建地

INACTIVE=-1 注:是否启用帐号过期停权,-1表示不启用;宽限天数,0及以下数皆为无效数字

EXPIRE= 注:帐号终止日期,不设置表示不启用;帐号失效日期(如:20081212)

SHELL=/bin/bash 注:所用SHELL的类型;登录后执行的程序

SKEL=/etc/skel 注: 用户家目录中的环境文件,默认添加用户的目录默认文件存放位置;也就是说,当我们用adduser添加用户时,用户家目录下的文件,都是从这个目录中复制过去的;
CREATE_MAIL_SPOOL=yes 注:是否创建用户邮件缓冲,yes表示创建
GROUPS:为useradd命令中的-G参数提供默认值,

3. /etc/skel– 新建用户时,会将该目录下的所有文件复制到新用户的家目录

设置用户密码passwd(略)

删除用户userdel

只有一个参数-r,表示删除用户同时删除该用户家目录下的所有文件。如果不加、则只删除用户而保留家目录。

管理用户(组)usermod

【命令格式】

usermod[option] username

【OPTION】

-A,--add-to-group group,...
将用户以追加的形式添加到若干个group中(即允许该用户拥有多个gid),注意与-G的区别

-c,--comment comment
This option specifies the new user’s finger information. It isnormally modified using the chfn(1) utility.

-d,--home homedir
为用户设定新的家目录.

-m,--move_home
更换用户家目录的同时、将原家目录下的文件拷贝过来. 但如果新的家目录已经存在, 命令会报错,并终止操作。

-e,--expire expire
指定用户过期的日志,格式为YYYY-MM-DD.也可以指定天数(自1970-1-1开始数起)

-f,--inactive inactive
用户过期后仍可登录的缓冲天数,如果设置为-1表示禁用该功能

-G,--groups group,...
可以为用户添加多个附加组(指supplementary groups,注意与-A选项的区别),使用逗号隔开.

-g,--gid gid
改变指定用户所属的用户组(gid). The group name mustexist and a group number must refer to an already existing group.

-l,--login name
Specify the new account name for the user. The account name mustbegin with an alphabetic character and the rest of the string should be fromthe POSIX portable character class. Nothing else is changed.

-o,--non-unique
Allow duplicate (non-unique) User IDs.

-u,--uid uid
Change the userid to be the given number. This value must be positive and unique (unless the -o option is used). Any file with the old UID of the user andwhich is located in the directory tree rooted at the user's home directory
willbe changed to be owned by the new UID automatically.

-p,--password password
Encrypted password as returned by crypt(3) as the new password.

-R,--remove-from-group group,...
将用户从一个或多个组中移除,组名用逗号分隔。

-s,--shell shell
修改用户登录后的默认shell

-D,--binddn binddn
Use the Distinguished Name binddn to bind to the LDAPdirectory. The user will be prompted fora password for simple authentication.

-L,--lock
锁定指定的用户、禁止其登录.

-U,--unlock
解锁用户,但如果该用户密码为空,则解锁失败。

-P,--path path
The passwd and shadow files are located below the specifieddirectory path. usermod will use this files, not /etc/passwd and /etc/shadow.

--serviceservice
Modify the account from a special directory. The default is files,but ldap is also valid.

--help
Print a list of valid options with a short description.

--usage
Print a short list of valid options.

-v,--version
Print the version number and exit.

【涉及的系统文件】

/etc/group- group information
/etc/passwd- user account information
/etc/shadow- shadow user account information

二、权限管理

属主和属组

当用户创建一个文件时:

# touch own

# ll own

-rw-r--r-- 1 root root0Dec 5 10:23 own

系统会自动为这个文件分配属主(即上面的root用户本身)、属组(即root用户对应的私有组root)及其他组用户对这个文件的权限。

上述属组/属主可以通过下面的命令进行更改

chown

【命令格式】
chown [option]user:group filename
最常用的option就是R,如果加上的话,会把目标目录及其下所有文件的属组和属主都改掉,不加的话则只更改指定的文件(夹)。
【OPTION】
-c,--changes
like verbose but report only when achange is made

--dereference
affect the referent of each symboliclink (this is the default), rather than the symbolic link itself

-h,--no-dereference
affect each symbolic link instead ofany referenced file (useful only on systems that can change the ownership of asymlink)

--from=CURRENT_OWNER:CURRENT_GROUP
change the owner and/or group of eachfile only if its current owner and/or group match those specified here. Eithermay be omitted, in which case a match is not required for the omitted attribute

--no-preserve-root
do not treat `/' specially (thedefault)

--preserve-root
fail to operate recursively on `/'

-f,--silent, --quiet
suppress most error messages

--reference=RFILE
use RFILE's owner and group rather thanspecifying OWNER:GROUP values

-R,--recursive
operate on files and directoriesrecursively

-v,--verbose
output a diagnostic for every fileprocessed

Thefollowing options modify how a hierarchy is traversed when the -R option isalso specified. If more than one is specified, only the
finalone takes effect.

-H if a command line argument is a symboliclink to a directory, traverse it

-L traverse every symbolic link to a directoryencountered
*普通用户是无法将自己文件的属组和属主传递给其他用户的。会提示Operation notpermitted

chgrp

这个命令只能修改文件的属组,而上面的chown命令已经完全包含了这个命令的功能,所以很少使用这个命令。可以通过man chgrp

文件权限

当用户创建一个文件时:

# touch own

# ll own

-rw-r--r-- 1 root root0Dec 5 10:23 own

系统会自动为这个文件分配属主(即上面的root用户本身)、属组(即root用户对应的私有组root)及其他组用户对这个文件的权限,上面的例子-rw-r--r—表示:

第一位-:表示这个一个文件,文件夹则用d表示

第二位r(4):表示该用户自己对这个文件具有读权限,-表示没有

第三位w(2):表示该用户自己对这个文件具有写权限,-表示没有

第四位-(1):表示该用户自己对这个文件没有执行权限,x表示有

第五位r(4):表示该用户所在组下的其他用户对这个文件具有读权限,-表示没有

第六位-(2):表示该用户所在组下的其他用户对这个文件没有写权限,w表示有

第七位-(1):表示该用户所在组下的其他用户对这个文件没有执行权限,x表示有

第八位r(4):表示其他组(即不包含该用户的组)下的用户对这个文件具有读权限,-表示没有

第九位-(2):表示其他组下的用户对这个文件没有写权限,w表示有

第十位-(1):表示其他组下的用户对这个文件没有执行权限,x表示有

通常也把第2,3,4位权限记为u,第5,6,7位记为g,第8,9,10三位的权限记为o(other),第2~10位权限记为a(all),如果记不住下面的“绝对权限”表示法,则可以通过这种表示进行权限变更操作。

*读、写、执行权限对于文件和文件夹来说,包含的操作有所不同:

一旦文件具备了执行权限(即x),该文件就可以通过./或定时任务执行;读和写就不解释了。

而文件的执行权限表示是否允许通过cd命令进入该目录;读权限则允许查看目录中的文件列表(比如ls命令);写权限则允许用户在该目录中创建文件。

*上文每一位后面的数字,表示这个权限对应的8进制数值,除第一位、后面每三位相加(-为0,不计算在内)会得出得出的三位8进制数,就是这个文件(夹)的8进制权限表示,上例中文件的权限也可以表示为644

上述权限都可以通过下面的命令进行更改

chmod

【命令格式】
chmod[option] <mode> file
【OPTION】
-c,--changes
like verbose but report only when achange is made

--no-preserve-root
do not treat `/' specially (thedefault)

--preserve-root
fail to operate recursively on `/'

-f,--silent, --quiet
suppress most error messages

-v,--verbose
output a diagnostic for every fileprocessed

--reference=RFILE
use RFILE's mode instead of MODE values

-R,--recursive
change files and directoriesrecursively

--helpdisplay this help and exit

--version
output version information and exit

【MODE】
Each MODE is of the form`[ugoa]*([-+=]([rwxXst]*|[ugo]))+'.

默认权限值umask

这个值决定了用户创建文件(夹)时,文件(夹)的默认权限。每个用户可以自定义自己的umask值。
*有时用户的umask值会是4位数,千位、也就是第一位表示的是下面说道的suid/sgid/sticky权限。详见下文
【计算方法】
文件夹-用777,减去umask值(如果不够三位、在前面补零);
文件-用666减去umask值;
得到的就是新文件(夹)创建后的默认权限。
【修改方法】
echo "umask 033" >>~/.bash_profile

source ~/.bash_profile

suid、sgid、sticky权限概述

【概念解释】
SUID属性只能运用在可执行文件上,当用户执行该执行文件时,会临时拥有该执行文件所有者的权限。passwd命令启用了SUID功能,所以一般用户在使用passwd命令修改密码时,会临时拥有了passwd命令所有者root用户的权限,这样一般用户才可以将自己的密码写入/etc/shadow文件。在使用“ls -l”或“ll”命令浏览文件时,如果可执行文件所有者权限的第三位是一个小写的“s”就表明该执行文件拥有SUID属性。
[root@srv~]# ll /usr/bin/passwd
-rwsr-xr-x 1 root root 22960 Jul 17 2006 /usr/bin/passwd
如果在浏览文件时,发现所有者权限的第三位是一个大写的“S”则表明该文件的SUID属性无效,比如将SUID属性给一个没有执行权限的文件。
SGID于SUID不同,SGID属性可以应用在目录或可执行文件上。当SGID属性应用在目录上时,该目录中所有建立的文件或子目录的拥有组都会是该目录的拥有组。比如“/charles”目录的拥有组是charles,当“/charles”目录拥有SGID属性时,任何用户在该目录中建立的文件或子目录的拥有组都会时charles;当SGID属性应用在可执行文件上时,其他用户在使用该执行文件时就会临时拥有该执行文件拥有组的权限。比如/sbin/apachectl文件的拥有组是httpd,当/sbin/apachectl文件有SGID属性时,任何用户在执行该文件时都会临时拥有用户组httpd的权限。在使用“ls
-l”或“ll”命令浏览文件或目录时,如果拥有组权限的第三位是一个小写的“s”就表明该执行文件或目录拥有SGID属性。
[root@srvtmp]# ll
total 4
drwxr-sr-x 2 root root 4096 Feb 15 22:25test4
-r-xr-sr-x 1 root root 6144 Feb 15 22:25 test6
如果在浏览文件时,发现拥有组权限的第三位是一个大写的“S”则表明该文件的SGID属性无效,比如将SGID属性给一个没有执行权限的文件。
Sticky属性只能应用在目录,当目录拥有Sticky属性所有在该目录中的文件或子目录无论是什么权限只有文件或子目录所有者和root用户能删除。比如当用户test8在“/charles”目录中建立一个文件并将该文件权限配置为777,当/charles目录拥有Sticky属性时,只有root和test8用户可以将该文件删除。在使用“ls -l”或“ll”命令浏览目录时,如果其他用户权限的第三位是一个小写的“t”就表明该执行文件或目录拥有Sticky属性。
[root@srv tmp]# ll
total 4
drwxrwxrwt2 root root 4096 Feb 15 22:34 test4
【配置SUID/SGID/Sticky属性】
配置普通权限时可以使用字符或数字,SUID、SGID、Sticky也是一样。使用字符时s表示SUID和SGID、t表示Sticky;4表示SUID、2表示SGID、1表示Sticky。在配置这些属性时还是使用chmod命令。举例:
#为文件test8增加SUID属性。在使用数字表示时,原来的三位不变,只是增加了一个千位专门用于SUID、SGID、Sticky属性。下面千位的4就是SUID属性,2是SGID属性,1表示sticky属性
[root@srv tmp]# chmod 4555 test8

#为目录test2增加SGID属性
[root@srv tmp]# chmod g+s test2

#为目录test3增加SGID属性
[root@srv tmp]# chmod 2755 test3/

#为文件test7增加SUID和SGID属性,6=4(SUID)+2(SGID)
[root@srv tmp]# chmod 6555 test7

#为目录test4增加Sticky属性
[root@srv tmp]# chmod o+t test4/

#为目录test5增加Sticky属性
[root@srv tmp]# chmod 1755 test5/

#为目录test1增加SGID和Sticky属性,3=2(SGID)+1(Sticky)。
[root@srv tmp]# chmod 3755 test1/

#执行上述更改命令后当前目录的情况
[root@srv tmp]# ll
drwxr-sr-x 2 root root 4096 Feb 15 22:47 test2
drwxr-sr-x 2 root root 4096 Feb 15 22:47 test3
drwxr-xr-t 2 root root 4096 Feb 15 22:46 test4
drwxr-xr-t 2 root root 4096 Feb 15 22:46 test5
-r-sr-xr-x 1 root root 5120 Feb 15 22:46 test6
-r-sr-sr-x 1 root root 3072 Feb 15 22:50 test7
drwxr-sr-t 2 root root 4096 Feb 15 22:56 test1
-r-sr-xr-x 1 root root 6144 Feb 15 22:48 test8
-r-xr-xr-x 1 root root 9216 Feb 15 22:51 test9
#取消目录test1的SGID属性。
[root@srv tmp]# chmod g-s test1/

*在使用umask命令显示当前的权限掩码时,千位的“0”就是表示SUID、SGID、Sticky属性。

提示:在有些资料上SUID、SGID被翻译为“强制位”,Sticky被翻译为“冒险位”。

三、POSIX(Portable Operation System Interface) ACL权限系统

首先要查看Linux的内核版本:
cat /proc/version
或者
uname -a
因为POSIX在2.6版上才被正式支持
其次,POSIX还需要文件系统支持,比如ext2,ext3,JFS等,如果因为文件系统不支持ACL,可以尝试重新挂载的方式:
mount -o remount,acl
/dev/sr1
其中,/dev/sr1表示磁盘挂载点
由于Linux原有的权限管理系统不够灵活(比如Windows,可以就某个具体的文件设置对某(些)用户(组)的权限,但从Unix继承来的权限系统很难做到这一点),因此推出了POSIX ACL。

【查看ACL权限命令-getfacl】

【命令格式】

getfacl [option] filename

对某个文件执行该命令后,会显示如下内容:

# file:ifconfig.sh
# owner:root
# group:root
# flags:ss-
user::rwx
group::r-x
other::---
user:: 两个:中间为空,表示这个文件的属主对该文件具备的权限
group:: 两个:中间为空,表示这个文件的属组对该文件具备的权限
other:: 两个:中间为空,表示这个所有其他用户(组)对该文件具备的权限
前四行(#所在行)则说明了这个文件的属组、属主、文件名以及suid/sgid/sticky权限。

【OPTION】

-a ,--access:显示文件或目录的访问控制列表。
-d ,--default:显示文件或目录的默认(缺省)的访问控制列表。
-c ,--omit-header:不显示默认的访问控制列表。
-R ,--recursive:操作递归到子目录。

【ACL权限管理命令】

【命令格式】

setfacl[option] <权限表达式> filename

【!ACL权限上线值mask!】

系统会为ACL设定一个默认的权限上限,当你要设置的ACL权限超过这个上限时,超出的权限会自动被系统屏蔽。

【OPTION】

-m 为某文件(夹)修改、新增ACL权限

举例:

#将上述root用户的ifconfig.sh文件的读、执行权只赋给cuser

setfacl -m u:cuser:rx ifconfig.sh

-b,--remove-all
删除所有扩展ACL权限
举例:setfacl –b filename

-d,--default
为文件设置默认的ACL权限,可以对某个目录设置一个默认的ACL权限,以后在这个目录下创建的文件(夹)就都默认有了这个ACL权限。需要配合m参数使用
*这里要注意,为文件(夹)赋ACL权限时,不能超过上面说的mask值,否则需要先更改该文件的默认mask值,如下:
setfacl -mmask::rwx file_name
举例:
#指定用户xk和oinstall组下的用户,对root文件夹下的所有新建文件(夹)拥有rwx权限
setfacl-dm u:xk:rwx,g:oinstall:rwx root/
getfacl--omit-header root/
user::rwx
user:xingkai:rwx
group::r-x
group:oinstall:rwx
mask::rwx
other::r-x
default:user::rwx
default:user:xingkai:rwx
default:group::r-x
default:group:oinstall:rwx
default:mask::rwx
default:other::r-x

-k,--remove-default
删除所有默认的ACL权限
举例:setfacl –k filename

-n,--no-mask
Do not recalculate the effective rightsmask. The default behavior of setfacl is to recalculate the ACL mask entry,unless a mask entry was explicitly given. The mask entry is set to the union ofall permissions of the owning group, and
all named user and group entries.(These are exactly the entries affected by the mask entry).

--restore=file
Restore a permission backup created by`getfacl -R' or similar. All permissions of a complete directory subtree arerestored using this mechanism. If the input contains owner comments or groupcomments, and setfacl is run by root, the
owner and owning group of all filesare restored as well. This option cannot be mixed with other options except`--test'.

--test
Test mode. Instead of changing the ACLsof any files, the resulting ACLs are listed.

-R,--recursive
Apply operations to all files anddirectories recursively. This option cannot be mixed with `--restore'.

-L,--logical
Logical walk, follow symbolic links todirectories. The default behavior is to follow symbolic link arguments, andskip symbolic links encountered in subdirectories. Only effective incombination with -R. This option cannot be mixed with
`--restore'.

-P,--physical
Physical walk, do not follow symboliclinks to directories. This also skips symbolic link arguments. Only effectivein combination with -R. This option cannot be mixed with `--restore'.

【权限表达式】

对象类型:对象名:权限列表

对象类型:即上文“文件权限”部分提到的u|g|o|a

对象名:即用户名、组名,如果为空、则表示对

权限列表:即rwx这三个值中的任一个或组合

同一条命令可以包含多个权限表达式,用逗号隔开

参考文章:
http://asmboy001.blog.51cto.com/340398/105706/
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息