Note: You are currently viewing my old web site. There is a new version with most of this content at OJB.NZ.
The new site is being updated, uses modern techniques, has higher quality media, and has a mobile-friendly version.
This old site will stay on-line for a while, but maybe not indefinitely. Please update your bookmarks. Thanks.


[Index] [Menu] [Up] Title[Header]
Terminal Tips

(Up to OJB's Mac Terminal Tips List Page)


Changing Privileges

Sometimes you might not be able to use files or access directories (folders) in 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.

More information: Getting Started.

Related commands: Listing Directory Contents.


[Up]

[Contact][Server Blog][AntiMS Apple][Served on Mac]

Comment on this page: Very UsefulQuite UsefulUseless or: View Results