قالب وردپرس درنا توس
Home / Tips and Tricks / How to set file permissions on Mac

How to set file permissions on Mac



  macOS Logo

Like all major operating systems, macOS allows you to restrict access to files with a complex set of file states. You can set these yourself with the Finder app or by using the chmod command in your Mac terminal. How to use.

Setting Mac File Permissions with Finder

To set the permissions for a file on your Mac without using the terminal, you must use the Finder app.

You can launch Finder from the Dock at the bottom of the screen. The application is represented by the smiling Happy Mac logo icon.

 Finder icon in macOS Dock

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

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

Comprehensive information about your file or folder can be found in the "Info" window that opens. However, to set file permissions, you must click the arrow next to the "Sharing and Permissions" option.

This displays a list of accounts or user groups on your Mac, with access levels displayed under the "Privilege" category.

If the account or user group you want to set permissions for is not listed, select the Plus icon (+) at the bottom of the window. [19659005]   Touch the plus icon at the bottom of the Get Info window

Select a user or group in the selection window and then click the "Select" button. This adds it to the list. [19659005]  Select a user or user group, then press Select to add that user or group to the file state list on macOS

Access levels are self-explanatory – users with a "read only" access level can't edit files, but they can access them. If an account is set to "Read & Write", they can do both.

To edit this for a user or group in the list, click you are on the arrow next to the existing level for that account or group and then select either "Read Only" or "Read & Write" in the list.

 Setting user group permissions for a user on macOS

Permissions are immediately set. Close the "Info" window when you are done.

Setting Mac File Permissions with the Terminal

If you have ever used the chmod command on Linux, you will be aware of its power. With a terminal command, you can set read, write and executable permissions for files and directories.

RELATED: How to use the chmod command on Linux

chmod command is not a Linux command, however. Like many other Linux terminal commands, chmod goes back to Unix from the 1970s – Linux and macOS both share this legacy, so the chmod command is available in macOS today. [19659005] Open a terminal window to use chmod . You can do this by touching the Launchpad icon on the Dock and clicking on the “Terminal” option in the “Other” folder.

 Touch the Dock icon on the Dock, and then click

Alternatively, you can use Apple's built-in Spotlight search to open the terminal.

View current file permissions

To see current permissions for a file, type:

  ls - @ l file.txt 

Replace "File.txt" with your own file name. This will display all user access levels, as well as any extended attributes relevant to macOS.

 The ls command on the macOS terminal

File permissions for the file appear in the first 11 character output of the ls command. The first character, a single dash ( - ), shows that this is a file. For folders, this is replaced by a letter ( d ).

 The ls command on the macOS terminal shows files and folders

The next nine characters are divided into groups of three.

The first group shows access levels for the file / folder owner (1), the middle group shows group permissions (2) and the last three shows permissions for other users (3). [19659005]   Supported file permissions with the ls command on the macOS terminal

You will also see letters here, for example r (read), w (write) and x (executor). These levels are always displayed in that order, for example:

  • --- would mean no read or write access, and the file is not executable.
  • r - would mean the file can be read but not written to, and the file is not executable.
  • rw- would mean that the file can be read and written to, but the file is not executable.
  • rx means the file can be read and run, but not written to.
  • rwx means that the file can be read, written and executed.

If the final character is a wide character ( @ ), then it means that the file or folder has extended file attributes related to security, giving some apps (such as Finder) sustained file access.

This is partly related to new security features introduced in macOS Catalina, although the Access Control List (ACL) has been a Mac feature since macOS X 10.4 Tiger back in 2005.

RELATED: How macOS Catalina's new security features work

Setting file permissions

To set file permissions, use the command chmod 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 u = rw, g = r, o = r file.txt 

The u flag sets permissions for file owner, g refers to the user group, while o refers to all other users. The use of an even sign ( = ) wipes all previous permissions for that category.

In this case, the file owner gets read and write access, while the user group and other users are given read access.

 The chmod command used on the macOS terminal

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

  chmod o + rw file.txt 

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

 An alternate use of chmod on the macOS terminal [19659005] You can use minus ( - ) to remove it instead, for example:

  chmod o-rw file. txt 

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

 Remove permissions from all other users using chmod on the macOS terminal

To wipe, add or remove user rights for all users, use the flag instead . For example:

  chmod a + rwx file.txt 

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


With great power comes with great responsibility, and it does not deny that the command chmod is a comprehensive and powerful tool for changing file permissions on Mac. For example, you can replace the letters ( rwx ) with a combination of three (or four) octal digits, up to 777 (to read, write and drive).

To read more about it, type man chmod on the terminal to read the full list of available flags and settings.




Source link