# How to get permission number by string : -rw-r--r--

```
r=4
w=2
x=1
```

in every group. Your example is 6(r+w=4+2)4(r=4)4(r=4).

Please check `stat`

output:

```
# stat .xsession-errors
File: ‘.xsession-errors’
Size: 839123 Blocks: 1648 IO Block: 4096 regular file
Device: 816h/2070d Inode: 3539028 Links: 1
Access: (0600/-rw-------) Uid: ( 1000/ lik) Gid: ( 1000/ lik)
Access: 2012-05-30 23:11:48.053999289 +0300
Modify: 2012-05-31 07:53:26.912690288 +0300
Change: 2012-05-31 07:53:26.912690288 +0300
Birth: -
```

The full permissions mode number is a 4-digit octal number, though most of the time, you only use the 3 least-significant digits. Add up each group in the permissions string, taking r=4, w=2, x=1. For example:

```
421421421
-rwxr-xr--
\_/ -- r+w+x = 4+2+1 = 7
\_/ -- r+_+x = 4+0+1 = 5
\_/ -- r+_+_ = 4+0+0 = 4 => 0754
```

Now, sometimes you'll see an odd modestring like this:

```
-rwsr-xr-T
```

The fourth digit is overloaded onto the `x`

bits in the modestring. If you see a letter other than `x`

there, then it means one of these "special" fourth-digit bits is set, and if the letter is lower case, then `x`

for that position is also set. So the translation for this one is:

```
4 2 1
421421421
-rwsr-xr-T
+ + + -- s+_+T = 4+0+1 = 5
\_/ -- r+w+s = 4+2+1 = 7 (s is lowercase, so 1)
\_/ -- r+_+x = 4+0+1 = 5
\_/ -- r+_+T = 4+0+0 = 4 (T is uppercase, so 0) => 05754
```

The standard UNIX way to show that a number is octal is to start it with a zero. GNU `chmod`

will assume the mode you're giving it is octal anyway, but it's safest to prepend the zero.

Finally, if you see a `+`

at the end of the modestring:

```
-rwxr-xr-x+
```

then that means the file has extended permissions, and you'll need more than `chmod`

. Look into the `setfacl`

and `getfacl`

commands, for starters.