mac设置文件权限_如何在Mac上设置文件权限

mac设置文件权限

mac设置文件权限

macOS Logo

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徽标图标表示。

The Finder icon in the macOS Dock

In a Finder window, you can view and set permissions by right clicking a file or folder and selecting the “Get Info” option.

在Finder窗口中,可以通过右键单击文件或文件夹并选择“获取信息”选项来查看和设置权限。

Right-click a file and press Get Info to access file permissions on macOS

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上显示帐户或用户组的列表,访问级别显示在“权限”类别下。

The "Sharing & Permissions" section of the Get Info window for a file on macOS

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.

如果您要为其设置权限的帐户或用户组未列出,请选择窗口底部的加号(+)图标。

Press the plus icon at the bottom of the Get Info window

Choose the user or group in the selection window and then click the “Select” button. This will add it to the list.

在选择窗口中选择用户或组,然后单击“选择”按钮。 这会将其添加到列表中。

Select a user or user group, then press Select to add that user or group to the list of file permissions on macOS

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.

要为列表中的用户或组编辑此内容,请单击该帐户或组的现有级别旁边的箭头,然后从列表中选择“只读”或“读写”。

Setting user group permissions for a user on macOS

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”选项来执行此操作。

Press the Launchpad icon on the Dock, then click the "Terminal" option in the "Other" folder to launch the Terminal app

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相关的任何扩展属性。

The ls command at the macOS terminal

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 ls command at the macOS terminal showing files and folders

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)。

Underlined file permissions using the ls command at the macOS terminal

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.

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

The chmod command used at the macOS terminal

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.

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

An alternative use of chmod at the macOS terminal

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.

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

Removing permissions from all other users using chmod at the macOS terminal

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设置文件权限

本文来自互联网用户投稿,该文观点仅代表作者本人,不代表本站立场。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如若转载,请注明出处:http://www.mzph.cn/news/278913.shtml

如若内容造成侵权/违法违规/事实不符,请联系多彩编程网进行投诉反馈email:809451989@qq.com,一经查实,立即删除!

相关文章

Discrete Log Algorithms :Baby-step giant-step

离散对数的求解 1.暴力 2.Baby-step giant-step 3.Pollard’s ρ algorithm …… 下面搬运一下Baby-step giant-step 的做法 这是在 https://ctf-wiki.github.io/ctf-wiki/crypto/asymmetric/discrete-log/discrete-log/ 上看到的,比较容易理解。 而且,…

Android添加item动画,RecyclerView基础篇-Item添加动画

Android_Banner.jpg简介本节中我们介绍下给RecyclerView中的Item添加动画。添加的动画,分为,在打开列表时有Item的展示动画,当滑动的时候没有动画和打开列表滑动时有动画两种实现过程实现一个列表效果如下Screenshot_2020-09-01-17-03-35-349…

geek_Ask How-To Geek:营救受感染的PC,安装无膨胀iTunes和驯服疯狂的触控板

geekYou’ve got questions and we’ve got answers. Today we highlight how to save your computer if it’s so overrun by viruses and malware you can’t work from within Windows, install iTunes without all the bloat, and tame a hyper-sensitive trackpad. 您有问…

第1课:接口测试和jmeter总结

接口测试 1. 接口的分类:webService和http api接口1) webService接口:是按照soap协议通过http传输,请求报文和返回报文都是xml格式,一般要借助工具来测试接口;2) http api接口:是按照…

极客时间和极客学院_极客历史记录的本周:Twitter的诞生,OS X十周年以及太空停留时间最长的时代即将结束...

极客时间和极客学院Every week we bring you interesting trivia and milestones from the archives of Geekdom. Today we’re taking a peek at the birth of Twitter, ten years of Mac OS X, and the longest space stay in history. 每周,我们都会为您带来有趣…

Android风格ppt,Material Design风格的快手PPT

突发奇想,感觉MD风格既然适合 Android 软件的界面,那么在一般PPT 演示中,效果当也是不错。于是在网上去寻了几处制作贴,也简单看了 MD 设计指南的几处要点。先试试一番再说。关于 MD 设计指南和几处制作贴,我会把链接贴…

dropbox链接过期_询问操作方法:“开始”菜单中的Dropbox,了解符号链接和翻录TV系列DVD...

dropbox链接过期This week we take a look at how to incorporate Dropbox into your Windows Start Menu, understanding and using symbolic links, and how to rip your TV series DVDs right to unique and high-quality episode files. 本周,我们来看看如何将D…

android listpreference 自定义,Android – 我的ListPreference中的自定义行布局

在我的Android应用程序中,我实现了从ListPreference扩展的类SubtitleColorListPreference.我需要这个,因为我需要为列表中的每个项目设置自己的布局.一切正常,它看起来像这样:重要的代码是onPrepareDialogBu​​ilder(AlertDialog.Builder builder)中的方法,我在其中…

火狐 增强查找工具栏_在“提示”框中:简单的IE至Firefox同步,轻松的Windows工具栏和识别USB电缆...

火狐 增强查找工具栏() Every week we tip into our mail bag and share great tips from your fellow readers. This week we’re looking at an easy way to sync your bookmarks between IE and Firefox, using simple Windows toolbars, and a clever way to ID USB cables…

Input Director使用一个键盘和鼠标即可控制多台Windows计算机

The problem is having two or more PC’s and having to go back and forth between workstation. Input Director solves the problem by allowing you to control multiple Windows systems with only one keyboard and mouse on the Master PC. 问题是拥有两台或更多台PC…

excel导入csv文件_如何将包含以0开头的列的CSV文件导入Excel

excel导入csv文件Microsoft Excel will automatically convert data columns into the format that it thinks is best when opening comma-separated data files. For those of us that don’t want our data changed, we can change that behavior. Microsoft Excel将在打开…

android 9.0新ui,SystemUI分析(Android9.0)

8种机械键盘轴体对比本人程序员,要买一个写代码的键盘,请问红轴和茶轴怎么选?一、SystemUI组成SystemUI是Android的系统界面,包括状态栏statusbar、锁屏keyboard、任务列表recents等等,都继承于SystemUI这个类&#xf…

chromebook刷机_如何为不支持Chrome操作系统的网站欺骗Chromebook用户代理

chromebook刷机Not all browsers handle websites the same, and if they don’t support your operating system or browser, you could be denied access. Luckily, you can spoof the user agent on Chrome OS to make it look like you use a completely different system.…

cocos android-1,cocos2dx在windows下开发,编译到android上(1)

转自:http://www.2cto.com/kf/201205/130697.html下面我给大家介绍下,用vs2010开发cocos2dx,然后如何使其编译到android上。步骤如下:1、必要条件,你的eclipse能把代码编译到安卓手机或虚拟机上,如果这一步…

中药ppi网络图太杂乱_太杂乱了吗? 这是您的iPhone,iPad,Android或台式机的15张简约壁纸...

中药ppi网络图太杂乱Busy wallpaper images don’t work very well on your iPhone, iPad, or any device where you need to have lots of icons on the screen. Here’s a set of minimalistic wallpaper images that won’t clutter up your desktop. 繁忙的墙纸图像在iPhon…

初学者java学习计划_初学者:计划在Windows 7 Media Center中录制直播电视的时间

初学者java学习计划If you’re a new user to Windows 7 Media Center you know it can act as a DVR and pause or record Live TV. You can set up a schedule for it to record your favorite TV programs as well. 如果您是Windows 7 Media Center的新用户,则知…

如何在Office 2007中查看关于对话框和版本信息

One of our favorite readers wrote in today asking how to tell if his Word 2007 installation was running Service Pack 1, since he couldn’t find the About dialog, which got me thinking… I bet most people don’t know where it is! 我们最喜欢的一位读者今天写信…

windows全局热键_在Windows中创建快捷方式或热键以清除剪贴板

windows全局热键Have you ever copied something to the clipboard that you don’t want to leave there in case somebody else is going to use your computer? Sure, you can copy something else to the clipboard real quick, but can’t you just make a shortcut or h…

获取outlook 会议_如何仅在Microsoft Outlook中仅获取您关注的电子邮件的通知

获取outlook 会议Some emails are more important than others. Rather than getting alerts every time an email arrives, configure Microsoft Outlook to only alert you when the important stuff hits your inbox, rather than any old email that can wait until you ch…

jq html 多一个引号,为什么jQuery模板会为某些字符串添加双引号

背景我正在使用jQuery模板,ASP.Net MVC Razor视图和Twitter.问题使用带有一些字符串的jQuery模板会自动导致这些字符串被包含在“细节我创建了一个如下所示的jQuery模板:before ${text.parseUserName().parseHashTag()} after${created_at}${prettyDate(created_at)…