Bre*_*ent 1 unix permissions acl
我最近删除了 ACL,因为我的教授需要复制某些文件。现在我知道我应该授予他的用户权限,而不是使用“setfacl -b”将其全部删除。在我的主目录中。
所以问题是如何使用 setfacl/getfacl 恢复或设置新的 ACL 到我的主目录?
您无法“恢复”通过 ACL 方式丢弃的内容。如果您知道之前设置的内容,则可以小心地重新恢复那些记住的 ACL。
在 Unix 系统上,对您来说最重要的标准是组和其他标准 - 它们不受 ACL 直接影响,但它们控制不受 ACL 控制的访问,您也必须确保它们正确。您需要决定什么适合您的环境。对于许多公司设置,允许组和其他人读取文件、执行程序以及读取和搜索(执行)目录是合适的:
chmod 644 file
chmod 755 program
chmod 755 directory
Run Code Online (Sandbox Code Playgroud)
如果你不应该让其他人借用你的课程作业,你就要明确规定,这样团体和其他人就根本不允许进入:
chmod 600 file
chmod 700 program
chmod 700 directory
Run Code Online (Sandbox Code Playgroud)
或者你可以混合搭配;允许灵活性并开放对主目录的访问,但限制该目录下的人员。在某些情况下,您可能只允许组或其他人对目录执行权限(并且只对文件进行读取)。那么其他人除非知道文件名,否则无法访问该文件,并且只能读取该文件,而不能修改该文件或保存该文件的目录。
不要忘记使用适当的 umask 设置,以便默认情况下使用正确的权限创建文件。对于很多人来说,umask 022 是合适的;组成员和其他人都不能写入文件或目录,但可以读取文件或执行程序。
这些都不需要 ACL。如果您想为某些组或用户而不是其他组或用户提供受控访问权限,那么您需要确保您具有适当的基本级别权限集,然后您可以为选定的用户或组有效地添加对您的文件或目录的权限。选择。
setfacl 的 Solaris 10 手册页显示命令语法为:
Run Code Online (Sandbox Code Playgroud)setfacl [-r] -s acl_entries file setfacl [-r] -md acl_entries file setfacl [-r] -f acl_file file
这没有提到问题中提到的“-b”选项,因此您可能使用不同的平台。请注意,ACL 控件将是 POSIX 1e,但实际上从未标准化,因此不同的平台在命令上实现略有不同的变体。
Solaris 10 手册页接着解释了如何设置描述的“acl_entries”部分,并指出默认部分只能应用于目录,但默认值将用于目录中的文件。
ACL Entry Description
u[ser]::perms File owner permissions.
g[roup]::perms File group owner permissions.
o[ther]:perms Permissions for users other than
the file owner or members of file
group owner.
m[ask]:perms The ACL mask. The mask entry indi-
cates the maximum permissions
allowed for users (other than the
owner) and for groups. The mask is
a quick way to change permissions
on all the users and groups.
u[ser]:uid:perms Permissions for a specific user.
For uid, you can specify either a
user name or a numeric UID.
g[roup]:gid:perms Permissions for a specific group.
For gid, you can specify either a
group name or a numeric GID.
d[efault]:u[ser]::perms Default file owner permissions.
d[efault]:g[roup]::perms Default file group owner permis-
sions.
d[efault]:o[ther]:perms Default permissions for users other
than the file owner or members of
the file group owner.
d[efault]:m[ask]:perms Default ACL mask.
d[efault]:u[ser]:uid:perms Default permissions for a specific
user. For uid, you can specify
either a user name or a numeric
UID.
d[efault]:g[roup]:gid:perms Default permissions for a specific
group. For gid, you can specify
either a group name or a numeric
GID.
Run Code Online (Sandbox Code Playgroud)
您需要决定除了您的教授之外还有谁需要访问文件。也许你的实验室合作伙伴会这样做;也许助教会这样做;也许是你的一整年(但不是你下面的年份 - 那些高于你的年份可能已经知道你所知道的)。但如果没有更多关于您的保护要求的信息,没有人可以为您提供更多帮助。一般来说,ACL 很容易出现错误 - 如果有的话,请谨慎使用,并使用标准 Unix 权限作为主要访问控制。
下次,我建议简单地通过添加(而不是删除)ACL 来允许您的教授加入 - 或者询问他希望您将文件复制到哪里(让他负责解决权限问题),或者将文件复制到一个目录,例如 $HOME/tmp/prof.jones,该目录的权限为 711,文件的权限为 644,并告诉他那里有哪些文件可供他复制。