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 chmod command on Linux, 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.

如果您曾经在Linux上使用过chmod命令,那么您将意识到它的强大功能。 使用一个终端命令,您可以设置文件和目录的读取,写入和可执行权限。

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 Spotlight Search feature to open the Terminal.

或者,您可以使用Apple内置的Spotlight搜索功能打开终端。

查看当前文件权限 (Viewing Current File Permissions)

To view current permissions for a file, type:

要查看文件的当前权限,请键入:

ls -@l file.txt

Replace “file.txt” with your own file name. This will show all user access levels, as well as any extended attributes relevant to macOS.

用您自己的文件名替换“ file.txt”。 这将显示所有用户访问级别以及与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 new security features 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 chmodcommand 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=r file.txt

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表示所有其他用户。 使用等号( = )会擦除该类别的所有先前权限。

In this instance, the file owner is gaining read and write access, while the user group and other users are gaining read access.

在这种情况下,文件所有者正在获得读写访问权限,而用户组和其他用户正在获得读取访问权限。

You can use a plus sign (+) to add access to a user level. For instance:

您可以使用加号( + )将访问权限添加到用户级别。 例如:

chmod o+rw file.txt

This would grant all other users both read and write access to the file.

这将授予所有其他用户对该文件的读写权限。

You can use the minus (-) to remove this instead, for example:

您可以使用减号( - )删除它,例如:

chmod o-rw file.txt

This would remove read and write access for all other users from the file.

这将从文件中删除所有其他用户的读写访问权限。

To wipe, add, or remove user permissions for all users, use the a flag instead. For instance:

要擦除,添加或删除所有用户的用户权限,请改用a标志。 例如:

chmod a+rwx file.txt

This would grant all users and user groups with read and write access to your file, as well as allow all users to execute the file.

这将授予所有用户和用户组对文件的读写权限,并允许所有用户执行文件。



With great power comes great responsibility, and there’s no denying that the chmod command is an extensive and powerful tool to change file permissions on Mac. You can, for instance, replace the letters ( rwx ) with a combination of three (or four) octal digits, up to 777 (for read, write, and execute).

强大的功能伴随着巨大的责任,而且不能否认chmod命令是在Mac上更改文件权限的强大工具。 例如,您可以将字母( rwx )替换为三个(或四个)八进制数字的组合,最大为777(用于读取,写入和执行)。

If you want to learn more about it, type man chmod at the terminal to read the full list of available flags and settings.

如果要了解更多信息,请在终端上键入man chmod以阅读可用标志和设置的完整列表。

翻译自: https://www.howtogeek.com/669095/how-to-set-file-permissions-on-mac/

mac设置文件权限

mac设置文件权限_如何在Mac上设置文件权限相关推荐

  1. macos必做的设置_如何在MacOS上设置PHP,CaddyServer和Kirby —以及为什么要这样做

    macos必做的设置 by Philipp Haidenbauer 菲利普·海登鲍尔(Philipp Haidenbauer) 如何在MacOS上设置PHP,CaddyServer和Kirby -以及 ...

  2. mac java 读取到服务器上的文件夹_如何在Mac和Win之间高效共享文件?mac和win文件高效共享教程

    隔空投送,相信是很多使用Mac的小伙伴常用的文件交换方式.但隔空投送需要主动发送文件对方才能够接收,那有没有办法能让你的小伙伴儿直接访问你Mac上的文件呢?本篇文章教你如何使用Mac的共享功能在局域网 ...

  3. mac 电脑资源库文件夹_如何在Mac上找到您的资料库文件夹

    mac 电脑资源库文件夹 When fixing problems on a Mac, sometimes you need to roll up your sleeves and directly ...

  4. mac os壁纸软件_如何在Mac OS X上更改桌面墙纸

    mac os壁纸软件 Whether your Mac is starting to show its age or you just want to freshen things up a bit, ...

  5. sublime text3 python找不到文件路径_如何在sublime3项目设置中设置python模块的搜索路径?ImportError: No module named *的解决办法...

    问题:之前使用pycharm,用的挺溜,但是电脑配置实在不争气,pycharm启动久了,耗去大量内存,导致运行起来越来越慢,于是转向使用sublime text. 把项目从pycharm切换到subl ...

  6. macos 切换账户_如何在macOS上设置访客用户帐户

    macos 切换账户 If you loan your Mac to a friend or family member, even for a short time, you may not wan ...

  7. facebook修改权限_如何在Facebook上更改您的名字

    facebook修改权限 Whether you've just gotten married, no longer identify with your birth name, or just wa ...

  8. icloud电脑设置_如何在Android上设置iCloud电子邮件访问

    icloud电脑设置 Ben Stockton 本·斯托克顿 If you switch from iPhone to Android, you don't have to ditch iCloud ...

  9. 在linux里复制文件命令_如何在Linux上使用“安装”命令复制文件

    在linux里复制文件命令 Fatmawati Achmad Zaenuri/Shutterstock.com Fatmawati Achmad Zaenuri / Shutterstock.com ...

最新文章

  1. redhat6.4 添加yum本地源和安装virtualbox增强组件
  2. 求复变函数的 Taylor 展式与 Laurent 展式[华中师范大学2010年复变函数复试试题]...
  3. vrep和matlab,VREP与MATLAB联合仿真程序--UR5机械臂动力学控制
  4. Java8函数式编程(2)--流与管道
  5. MS SQL入门基础:数据库中的锁
  6. sqlserver oracle对比,sqlserver和oracle常用函数对比
  7. cmdb整体项目梳理(2)
  8. JavaScript重难点解析6(Promise)
  9. 机房部署环境和划分多vlan的好处
  10. 能编写PHP语言吗_语言能力差口才不好,靠看书就能提高吗
  11. PGIS中java程序授权问题
  12. lvm扩容-缩减磁盘
  13. php qcloud sdk weapp_qcloud/
  14. 西部数据将旗下绿盘系列产品归入为蓝盘系列产品
  15. 自动化测试的定位及一些思考
  16. 虚拟机里centos7怎么联网?费时许久终于搞定!!
  17. 福昕:十年暗战Adobe
  18. idead导入maven多模块
  19. vb.net 教程 12-4 msHtml 1
  20. php post 漏洞_文件包含上传漏洞目录遍历命令执行漏洞

热门文章

  1. 基于PHP+MySQL实现注册和登录功能
  2. 【Proteus仿真】Arduino+uln2003驱动步进电机+单按键启保停正反转控制
  3. 【Proteus仿真】Arduino UNO利用Stepper库实现uln2003驱动步进电机转动
  4. 社群的使用---Kodu少儿编程第八天
  5. html怎么做下雨效果,Canvas制作的下雨动画的示例
  6. 持续更新就是给软件上医保
  7. 尺取法(图文解析、初学推荐)
  8. django实现腾讯云短信sdk和redis缓存服务,手机号验证码登录,未注册直接注册登录
  9. 益智拼图APP隐私政策
  10. 双目立体视觉建立深度图_从单幅图像到双目立体视觉的3D目标检测算法