Site TIPS PAGE🔎 SEARCH  Ξ INDEX  MAIN MENU  UP ONE LEVEL
 OJB's Web Site. Version 2.1. Mac Tip.You are here: tip tips mac owen2 
Tip

Up to OJB's Mac Tips List

Terminal: Changing Privileges

Sometimes you might not be able to use files or access directories (folders) in macOS (or OS X or Mac OS X) because you don't have sufficient privileges. This can be corrected using the "Ownership and Permissions" section of the Get Info dialog from the Finder, but it is often much faster and easier to make these changes from the command line, especially if you need to change a large number of files.

There are three main command involved in changing privileges, they are "chown", which changes the owner of a file, "chgrp", which changes the group associated with a file, and "chmod" which changes the "mode" or what different users can do with the file.

To display the current privileges associated with a file use the "ls -l" command. The first column should contain a cryptic collection of characters like "-rw-r--r--". The third column will contain the name of a user, such as "owen", and the fourth column will contain the name of a group, such as "staff".

For most of the files in your documents folder the owner will be the short name you set up when you first configured the system. The group will usually be one of the standard groups the system sets up, most often "staff". The other column is a bit trickier. It shows what access the the owner (user), group and other users have to the item.

For example, if the specification is "-rw-r--r--" it means the owner has read and write access (but not execute) as shown by "rw-" in characters 2 to 4 (ignore character 1 at this point). Characters 5 to 7 show the group's privileges, "r--" meaning read but no write or execute. Characters 8 to 10 show the access other users have, also just read. In other words, the owner (owen) can read and write (including change and delete) this file, the group (staff, usually a group containing all other users of that machine) and any other user not in that group can read it but can't change or delete it.

To change the owner of a file use "chown". For example to change the owner of a file "Stuff.txt" to "fred" type "chown fred Stuff.txt". To change the group use "chgrp". To set the group associated with the file to staff use "chgrp staff Stuff.txt". To specify what the user and group can do use "chmod". To give the owner read and write access, the group read only and other users no access, use "chmod u=rw,g=r,o= Stuff.txt".



I usually write a blog post about once a week. The latest post can be viewed here: Deranged Rants: Many of them are totally feral, unhinged, and totally irrational. (posted 2024-11-13 at 17:55:14). I do podcasts too!. You can listen to my latest podcast, here: OJB's Podcast 2024-08-22 Stirring Up Trouble: Let's just get every view out there and fairly debate them..
 Site ©2024 by OJBRSS FeedWhy Macs are BestMade & Served on Mac 
Site Features: Blog RSS Feeds Podcasts Feedback Log07 Jun 2024. Hits: 157,912,654
Description: Mac TipKeywords: Macintosh,Computers,Fixing Problems,TipsLoad Timer: 11ms