Ask Different is a question and answer site for power users of Apple hardware and software. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

How can I see the permissions for a file (e.g. if I want to recreate those permissions for another file using chmod)?

For example after I run chmod 644 on foo.txt, what command, if any, can I run on foo.txt which returns 644?

share|improve this question
You might want to try at if you don't get any answers here. All I know of is ls -l foo.txt which will give you the rwxrwx--- string which you can convert to octal yourself (but I guess you know that already). – Lizzan Oct 18 '10 at 18:30
up vote 2 down vote accepted

If you type ls -l in terminal you get the permission for your file

drwxr-xr-x   7 ---  staff   238 Apr 14  2010 images
-rw-r--r--   1 ---  staff  2628 Aug 26  2009 index.html
drwxr-xr-x@ 11 ---  staff   374 Feb 28  2010 simplemvc

You can use table below to convert rwxr-xr-x to number and vice versa:

alt text

And get more detail here.

share|improve this answer

The easiest way to get the octal permissions from the command line is by using stat(1) with a format specifier.

You can read more in the manual page, but the following will give you what you want:

stat -f "%OMp%OLp" <file or directory>

%OMp returns the setuid/setgid/sticky bits in octal and %OLp the user/group/other permissions in octal.

For example:

$ ls -ld Data
drwxr-xr-x  6 mj  staff  204 20 Feb 11:09 Data
$ stat -f "%OMp%OLp" Data   
share|improve this answer

The easiest way I'm aware of that will list all permissions, including ACLs, is simply to use the Get Info command from the Finder on the concerned file.

share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.