LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Newbie (https://www.linuxquestions.org/questions/linux-newbie-8/)
-   -   Any way to show the permissions with numbers instead of with letters? (https://www.linuxquestions.org/questions/linux-newbie-8/any-way-to-show-the-permissions-with-numbers-instead-of-with-letters-811890/)

tirengarfio 06-03-2010 05:44 AM

Any way to show the permissions with numbers instead of with letters?
 
Hi,

any way to show the permissions with numbers (777) instead of with letters (drwxrwxrwx) using "ls" command or any other command ?

Regards

Javi

alli_yas 06-03-2010 05:56 AM

Hi

Not that I'm aware off.

It's pretty easy to convert though.

Basically think of each triplet (owner is a triplet, group is a triplet and anonymous is a triplet) as an octal number. Then in the triplet you have either a - or one of r, w or x . Think of a - as being a zero and a r, w or x as being a 1.

Lastly, in the triplet, each position represents 421 in that order (so r is a 4, w is a 2 and x is a 1); so rwxrwxrwx is basically 421421421 - to convert to the decimal representation you just add the elements of each triplet.

Thus a listing like rwxr-xr-x translates into a 755. Kinda tricky but you'll get the hang of it:)

Kenhelm 06-03-2010 05:20 PM

The output of GNU Coreutils 'stat' can be formated using the '-c' option.
http://www.gnu.org/software/coreutil...tat-invocation
Code:

stat -c '%a' file.ext
644

stat -c '%n %a' file.ext
file.ext 644

stat -c 'The access rights in octal of %n are %a' file.ext
The access rights in octal of file.ext are 644



All times are GMT -5. The time now is 06:21 AM.