Site TIPS PAGE🔎   UP ONE LEVEL
 OJB's Web Site. V 2.1.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".



My latest blog post: Unity Through Division: Sometimes hard decisions need to be made to make genuine progress. (posted 2024-11-18). My latest podcast: OJB's Podcast 2024-08-22 Stirring Up Trouble.
 ©2024 by OJBRSS FeedMS Free ZoneMac Made
T: 11. H: 170,380,722
Features: RSS Feeds Feedback LogMod: 07 Jun 2024