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.pswp.cn/news/278913.shtml
繁體地址,請注明出處:http://hk.pswp.cn/news/278913.shtml
英文地址,請注明出處:http://en.pswp.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…

Oracle數據庫查詢用 where in 查詢的項超過1000條的解決方案

眾所周知,如果我們的用SQL查詢語句時,如果用where in帶的參數超過1000條的話,oracle是會報錯的。 因為項目中遇到這樣的問題,所以找到了接下來我要說的這個辦法。 因為用的地方很多,所以我把這個封裝成了一個方法。 //…

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接口:是按照…

android 工作日,如何在Android上重復警報工作日

小編典典請嘗試此代碼。已在我的應用中成功運行if (chk_monday.isChecked()) {forday(2);} else if (chk_tuesday.isChecked()) {forday(3);} else if (chk_wednesday.isChecked()) {forday(4);} else if (chk_thursday.isChecked()) {forday(5);} else if (chk_friday.isCheck…

hdu4419

對于這類面積覆蓋的題,大致就兩點要注意的 1.同一把矩形放在笛卡爾坐標系上做 2.pushup函數要注意下細節:及在統計子區間和之前要先判斷是否有子區間 用sum數組來保存區間被覆蓋的情況,如果遇到多次覆蓋問題,那就開多個sum數組分別保存被覆蓋…

最簡單 - 單例模式

public class Person {// Person 引用private static Person p null;static {if (p null) {p new Person();}}/***單例模式獲取Person對象. * return*/public static Person getInstance(){return p;} ?} 復制代碼轉載自: 簡書 - 低至一折起 文章:w…

極客時間和極客學院_極客歷史記錄的本周: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 設計指南和幾處制作貼,我會把鏈接貼…

11月16日站立會議

今天是沖刺階段的第二天,我今天做了統計在線人數模塊的編寫而且對其進行了測試并修改完成,為團隊制作了今日的燃盡圖。 明天我要完成服務器端可以斷開所有用戶連接的一個小模塊和繼續為團隊制作燃盡圖。 今天遇到的困難是用Java進行編寫時,出…

iOS核心動畫高級技術(十三) 高效繪圖

More computing sins are committed in the name of efficiency (without necessarily achieving it) than for any other single reason—including blind stupidity. 不必要的效率考慮往往是性能問題的萬惡之源。 ——William Allan Wulf #軟件繪圖 術語繪圖通常在Core Anima…

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)中的方法,我在其中…

springMVC3學習(十一)--文件上傳CommonsMultipartFile

版權聲明:本文為博主原創文章,未經博主同意不得轉載。 https://blog.csdn.net/itmyhome/article/details/27976873 使用springMVC提供的CommonsMultipartFile類進行讀取文件須要用到上傳文件的兩個jar包 commons-logging.jar、commons-io-xxx.jar1、在sp…

基于React和SpringBoot的快速開發模板QuickAdmin

經過一段時間的總結和完善,我的管理系統快速開發模板已經基本成型,現在GitHub上開源啦: QuickAdmin QuickAdmin是基于Spring Boot和React.js實現的管理系統開發框架。用于開發網站的后臺管理系統。 本框架提供了如下功能: 完整的基…

android sim iso,android – 意外的telephonyManager.getSimCountryIso()行為

您可以使用MCC MNC獲取SIM卡國家/地區,它是SIM配置的,與您所在的網絡無關.Configuration config getResources().getConfiguration();int countryCode config.mcc;您可以在此處找到MCC列表MccTable.java例如,西班牙是214,法國是208MCC should work on all GSM devices with S…

火狐 增強查找工具欄_在“提示”框中:簡單的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…

day22 模塊-collections,time,random,pickle,shelve等

一、引入模塊的方式: 1. 認識模塊 模塊可以認為是一個py文件. 模塊實際上是我們的py文件運行后的名稱空間 導入模塊: 1. 判斷sys.modules中是否已經導入過該模塊 2. 開辟一個內存 3. 在這個內存中執行該py文件 4. 給這個內存起個名字, 一般用的是py文件的名字。返回…

基于Redis實現分布式鎖,避免重復執行定時任務

Spring提供了定時任務的功能,但是在多個實例的集群中,會出現定時任務重復執行多次的情況。 使用Qutaz框架自帶的分布式定時任務可以很好的解決這個問題,但是講道理功能有些過于強大,對于需求不高,乃至可以一定程度上允…