I can never remember what the conversion is from something like rw-r--r-- to 644. Is there a simple web based converter between the 2?
7 Answers
This site provides an interactive way to see what permissions bits are set when various bits are set/unset.
The "calculator" looks like this:

- 6The link is broken now, which is why we generally discourage link-only answers, but it's hard to criticize when the question asked for a linkMichael Mrozek– Michael Mrozek2012-11-04 19:45:57 +00:00Commented Nov 4, 2012 at 19:45
Why do you need an octal number in the first place?
I always use:
chmod o+x file # all + eXecute permissions chmod g-w file # group - write perms chmod u=r file # user can just read chmod ug=rw file # user,group = read and write chmod a+w file # user,group,others + write ugo(a) is easy to remember. However, you can confuse o:=owner? o:=other? But what would be u, if o=owner? u:=user, therefore o=other.
Some commands like numerical permissions only. Okay, it's not hard to calculate, if you remember the two sequences: ugo + rwx.
r w x | Sum u 4 2 1 | 7 g 4 - 1 | 5 o 4 2 - | 6 --------------------- 756 Yes, very artificial.
When it comes to s and S I have to consult the manual. Maybe google next time. :)
- Other programs that can have permissions don't always provide support for the semantic strings since the underlying interface is octal and easier to support. The first part of this answer is condescending and unnecessary. Just answer the question...salotz– salotz2020-05-26 19:40:31 +00:00Commented May 26, 2020 at 19:40
- 2If you read my answer as condescending you're misinterpreting the tone.user unknown– user unknown2020-05-26 20:10:54 +00:00Commented May 26, 2020 at 20:10
- > Why do you need an octal number in the first place?salotz– salotz2020-05-27 14:57:21 +00:00Commented May 27, 2020 at 14:57
- > "Some commands like numerical permissions only." I may add: Some documentation only lists numerical values.user unknown– user unknown2020-05-28 00:26:10 +00:00Commented May 28, 2020 at 0:26
Octal is used for permissions because it's an easy conversion. Each group of rwx forms one octal digit. All you have to remember is the first 3 powers of 2: 4, 2, 1. r = 4, w = 2, x = 1.
rw-r--r-- = 110 100 100 = 4+2+0 4+0+0 4+0+0 = 644
I like this permissions calculator:
http://file-permissions.ninja
- Normally, I would flag this for being a link-only answer, but since the OP was explicitly asking for a website, I will let it pass. Be aware though that link-only answers are often discouraged.HalosGhost– HalosGhost2014-10-17 20:11:39 +00:00Commented Oct 17, 2014 at 20:11
- This site doesn't seem to work right now. I see "403" errors in the console.Ryan– Ryan2019-09-14 22:39:15 +00:00Commented Sep 14, 2019 at 22:39
- +1 for a calculator that calculates permissions to/from the "ls" format (i.e. -rwx--S---)kbulgrien– kbulgrien2020-07-16 17:32:42 +00:00Commented Jul 16, 2020 at 17:32
- This is the only answer that directly answers the questionyeah22– yeah222020-11-07 00:12:28 +00:00Commented Nov 7, 2020 at 0:12
I have this little alias that you can put in your .bashrc (or equivalent).
DISCLAIMER: I am not the author of the script, and I'm not sure who wrote it... but props to him/her for doing this.
alias lsp="ls -l --color | awk '{k=0; for(i=0;i<=8;i++) k+=((substr(\$1,i+2,1)~/[rwx]/)*2^(8-i)); if (k) printf(\" %0o \",k); print}'" - 1Many thanks for that, @nico - here is the same code converted as a perl one-liner, and used in bash:
echo 'rwxrwxrw-' | perl -ne 'BEGIN{sub conv{ chomp(my $ins=shift); my $k=0; for(my $i=0;$i<=8;$i++) { my $tmps = ( substr($ins, $i, 1) =~ /[rwx]/ ); $k+= ( $tmps*(2**(8-$i)) ); }; if ($k) { sprintf(" %0o ", $k); } else { "??" ; }; }; } print(conv($_)."\n");'would print "776". Cheers!sdaau– sdaau2014-07-16 06:04:28 +00:00Commented Jul 16, 2014 at 6:04 - Sadly the scripts above are incomplete and do not handle setuid/setgid/sticky permissions.kbulgrien– kbulgrien2020-07-16 17:35:06 +00:00Commented Jul 16, 2020 at 17:35
This is by far the most convenient, and is besides I believe, exactly what you asked for originally:
http://ss64.com/osx/chmod.html
It is fully interactive, though you cannot edit the string "-r-x-------" but you can the octal or the checkboxes. Doing either updates the other.

From the same page:
Numeric (absolute) mode:
From one to four octal digits Any omitted digits are assumed to be leading zeros.
The first digit = selects attributes for the set user ID (4) and set group ID (2) and save text image (1) The second digit = permissions for the user who owns the file: read (4), write (2), and execute (1) The third digit = permissions for other users in the file's group: read (4), write (2), and execute (1) The fourth digit = permissions for other users NOT in the file's group: read (4), write (2), and execute (1)
The octal (0-7) value is calculated by adding up the values for each digit User (rwx) = 4+2+1 = 7 Group(rx) = 4+1 = 5 World (rx) = 4+1 = 5 chmod mode = 0755
- This "calculator" is broken with respect to 4-digit numbers even though the text talks about 4-digits. i.e. Entering 2777 should show "-rwxrwsrwx", but "--w-rwxrwx" is shown instead.kbulgrien– kbulgrien2020-07-16 17:26:37 +00:00Commented Jul 16, 2020 at 17:26
- there is a fith digit, the mac/dac levelMax Muster– Max Muster2023-06-03 13:50:44 +00:00Commented Jun 3, 2023 at 13:50
Even though this is not a "web" calculator, since nico's answer does not handle setuid, setgid, and sticky indicators, but does get up-votes, an example of an updated scriptlet that handles the extra permissions states may be warranted:
ls -l | \ awk '{k=0; for(i=0; i<=8; i++) k+=((substr($1, i+2, 1) ~ /[rwxs]/)*2^(8-i)); if ($1 ~ /^.{3}[Ss]/) k+=2048; if($1 ~ /^.{6}[Ss]/) k+=1024; if ($1 ~ /[Tt]/) k+=512; if(k) printf("%4o ",k); print; }' This question is a better fit for scripted solutions where glenn jackman offers a perl stat one-liner similar to:
$ what="/tmp" $ perl -s -e '@fields = stat "$f"; printf "%04o\n", $fields[2] & 07777' -- -f="$what" 1777 The awk script is based on one found here
- That's great, I will definitely update my .bashrc now! :)nico– nico2020-07-17 09:30:21 +00:00Commented Jul 17, 2020 at 9:30
stat -c...chmodnot support the symbolic mode. I have been told that most do. The Gnu one defiantly dose. e.g. turn on group writechmod g+w, set the moderw-r--r--chmod =r,u+worchmod u=rw,go=r.