mac设置⽂件权限_如何在Mac上设置⽂件权限
mac设置⽂件权限
Like all major operating systems, macOS allows you to restrict access to files using a complex set of file permissions. You can set these yourself using the Finder app, or by using the chmod command in your Mac’s terminal. Here’s how.
与所有主要操作系统⼀样,macOS允许您使⽤⼀组复杂的⽂件权限来限制对⽂件的访问。 您可以使⽤Finder应⽤程序或在Mac终端中使⽤chmod命令⾃⾏设置这些设置。 这是如何做。
使⽤Finder设置Mac⽂件权限 (Setting Mac File Permissions Using Finder)
If you want to set the permissions for a file on your Mac without using the terminal, you’ll need to use the Finder app.
如果要在不使⽤终端的情况下为Mac上的⽂件设置权限,则需要使⽤Finder应⽤程序。
You can launch Finder from the Dock at the bottom of your screen. The application is represented by the smiling Happy Mac logo icon.
您可以从屏幕底部的Dock启动Finder。 该应⽤程序由微笑的Happy Mac徽标图标表⽰。
In a Finder window, you can view and set permissions by right clicking a file or folder and selecting the “Get Info” option.
在Finder窗⼝中,可以通过右键单击⽂件或⽂件夹并选择“获取信息”选项来查看和设置权限。
Extensive information about your file or folder can be found in the “Info” window that opens. To set file permissions, however, you’ll need to click on the arrow next to the “Sharing & Permissions” option.
在打开的“信息”窗⼝中可以到有关⽂件或⽂件夹的⼤量信息。 但是,要设置⽂件许可权,您需要单击“共享和许可权”选项旁边的箭头。
This will display a list of accounts or user groups on your Mac, with access levels shown under the “Privilege” category.
这将在Mac上显⽰帐户或⽤户组的列表,访问级别显⽰在“权限”类别下。
If the account or user group you want to set permissions for isn’t listed, select the Plus (+) icon at the bottom of the window.
如果您要为其设置权限的帐户或⽤户组未列出,请选择窗⼝底部的加号(+)图标。
Choose the user or group in the selection window and then click the “Select” button. This will add it to the list.
在选择窗⼝中选择⽤户或组,然后单击“选择”按钮。 这会将其添加到列表中。
The access levels are self-explanatory—users with a “Read Only” access level are unable to edit files, but they can access them. If an account is set to the “Read & Write” level, then they can do both.
访问级别是不⾔⾃明的-具有“只读”访问级别的⽤户⽆法编辑⽂件,但可以访问它们。 如果将帐户设置为“读和写”级别,则它们可以同时执⾏。
To edit this for a user or group in the list, click on the arrow next to the existing level for that account or group and then select either “Read Only” or “Read & Write” from the list.
要为列表中的⽤户或组编辑此内容,请单击该帐户或组的现有级别旁边的箭头,然后从列表中选择“只读”或“读写”。
怎么设置文件夹权限Permissions are immediately set. Close the “Info” window once you’re done.
权限将⽴即设置。 完成后,关闭“信息”窗⼝。
使⽤终端设置Mac⽂件权限 (Setting Mac File Permissions Using the Terminal)
If you’ve ever used the , then you’ll be aware of its power. With one terminal command, you can set the read, write, and executable permissions for files and directories.
如果您曾经使⽤过,那么您将意识到它的强⼤功能。 使⽤⼀个终端命令,您可以设置⽂件和⽬录的读取,写⼊和可执⾏权限。
The chmod command isn’t a Linux-only command, however. Like many other Linux terminal commands, chmod dates back to Unix from the 1970s—Linux and macOS both share this heritage, which is why the chmod command is available in
macOS today.
但是, chmod命令不是仅Linux命令。 像许多其他Linux终端命令⼀样, chmod可以追溯到1970年代的Unix — Linux和macOS都具有这种传统,这就是为什么chmod命令在当今的macOS中可⽤的原因。
To use chmod, open a terminal window. You can do this by pressing the Launchpad icon on the Dock and clicking the “Terminal” option in the “Other” folder.
要使⽤chmod ,请打开⼀个终端窗⼝。 您可以通过按下Dock上的Launchpad图标并单击“ Other”⽂件夹中的“ Terminal”选项来执⾏此操作。
Alternatively, you can use Apple’s built-in feature to open the Terminal.
或者,您可以使⽤Apple内置的功能打开终端。
查看当前⽂件权限 (Viewing Current File Permissions)
To view current permissions for a file, type:
要查看⽂件的当前权限,请键⼊:
ls -@
Replace “” with your own file name. This will show all user access levels, as well as any extended attributes relevant to macOS.
⽤您⾃⼰的⽂件名替换“ ”。 这将显⽰所有⽤户访问级别以及与macOS相关的任何扩展属性。
File permissions for the file are shown in the first 11 characters output by the ls command. The first character, an en dash (-), shows that this is a file. For folders, this is replaced by a letter (d) instead.
ls命令输出的前11个字符显⽰了⽂件的⽂件许可权。 第⼀个字符,破折号( - )表⽰这是⼀个⽂件。 对于⽂件夹,将其替换为字母( d )。
The next nine characters are split into groups of three.
接下来的9个字符分为三个组。
The first group shows the access levels for the file/folder owner (1), the middle group shows group permissions (2), and the final three shows permissions for any other users (3).
第⼀组显⽰⽂件/⽂件夹所有者的访问级别(1),中间组显⽰组权限(2),最后三个组显⽰任何其他⽤户的权限(3)。
You’ll see letters here, too, such as r (read), w (write), and x (execute). These levels are always shown in that order, so for instance:
您还将在这⾥看到字母,例如r (读), w (写)和x (执⾏)。 这些级别始终按该顺序显⽰,例如:
--- would mean no read or write access, and the file isn’t executable.
---表⽰没有读写访问权限,并且该⽂件不可执⾏。
r-- would mean the file can be read, but not written to, and the file isn’t executable.
r--表⽰该⽂件可以读取,但不能写⼊,并且该⽂件不可执⾏。
rw- would mean the file can be read and written to, but the file isn’t executable.
rw-表⽰可以读取和写⼊⽂件,但该⽂件不可执⾏。
r-x means the file can be read and executed, but not written to.
rx表⽰该⽂件可以读取和执⾏,但不能写⼊。
rwx means the file can be read, written, and executed.
rwx表⽰可以读取,写⼊和执⾏⽂件。
If the final character is an at sign (@), then it signifies that the file or folder has extended file attributes relating to security, giving certain apps (like Finder) persistent file access.
如果最后⼀个字符是at符号( @ ),则表⽰⽂件或⽂件夹具有与安全性有关的扩展⽂件属性,从⽽使某些应⽤程序(如Finder)具有持久的⽂件访问权限。
This is related in part to introduced in macOS Catalina, although file access control lists (ACLs) have been a Mac feature since macOS X 10.4 Tiger back in 2005.
这部分与macOS Catalina中引⼊的有关,尽管⾃2005年macOS X 10.4 Tiger起,⽂件访问控制列表(ACL)⼀直是Mac的功能。
设置⽂件权限 (Setting File Permissions)
To set file permissions, you’ll use the chmod command at the terminal. To remove all existing permissions, set read and write access for the user while allowing read access for all other users, type:
要设置⽂件许可权,您将在终端上使⽤chmod命令。 要删除所有现有权限,请设置⽤户的读写访问权限,同时允许所有其他⽤户的读写访问权限,键⼊:
chmod u=rw,g=r,o=
The u flag sets the permissions for the file owner, g refers to the user group, while o refers to all other users. The use of an equal sign (=) wipes all previous permissions for that category.
u标志设置⽂件所有者的权限, g表⽰⽤户组,⽽o表⽰所有其他⽤户。 使⽤等号( = )会擦除该类别的所有先前权限。
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系QQ:729038198,我们将在24小时内删除。
发表评论