Sunday, December 4, 2022

#1 2005-10-12 06:04:08 am

From:: Malasaña, Madrid
Registered: 2002-11-20
Posts: 2014

How do I change permissions of a file/folder?

The quickest way is using the shell utility chmod, using octal numbers, where these mean the following:

Octal Display Permissions
0 --- None
1 --x Write
2 -w- Write
3 -wx Write and execute
4 r-- Read
5 r-x Read and execute
6 rw- Read and write
7 rwx Read, write and execute

You must use three numbers, one for each of owner, group and others. Eg:


do shell script "chmod 444 /path/to/file"

This will change the permissions of a file to 444, which is read-only for everybody.

You can also use the Finder, using the following syntax:


tell application "Finder"
   set owner privileges of alias "path:to:file" to read only
end tell

The Finder doesn't support the execution bit, since the Finder actually doesn't see a file as executable using this flag, but based on the kind of item (eg, if it is an application, it can be executed).

More info on permissions, see the Finder's dictionary under the item class or type "man chmod" in a Terminal window.

Filed under: Finder



Board footer

Powered by FluxBB

RSS (new topics) RSS (active topics)