After looking at the man
page for ls
on my system and searching Google, I see there IS a hack of way to use awk
or perl
to show octal permissions when using ls
, but with bash
is there anything more native?
Standard output of ls -alh
$ ll
total 0
drwxr-xr-x 5 user group 170B May 20 20:03 .
drwxr-xr-x 17 user group 578B May 20 20:03 ..
-rw-r--r-- 1 user group 0B May 20 20:03 example
-rw-r--r-- 1 user group 0B May 20 20:03 example-1
-rw-r--r-- 1 user group 0B May 20 20:03 example-3
Desired output including octal representation of permissions
$ ll
total 0
drwxr-xr-x 1775 5 user group 170B May 20 20:03 .
drwxr-xr-x 1775 17 user group 578B May 20 20:03 ..
-rw-r--r-- 1644 1 user group 0B May 20 20:03 example
-rw-r--r-- 1644 1 user group 0B May 20 20:03 example-1
-rw-r--r-- 1644 1 user group 0B May 20 20:03 example-3
(disclaimer: not sure if those octals are exactly right)
Reasoning
I am more familiar with the drwxr-xr-x
notation for permissions but sometimes when the dashes fall in odd places I might mis-read it at a quick glance. I'd like to see the octal equivalent as well.
Conversion Ability (question part 2)
I think a long time ago octal permissions might have been limited to 000
- 777
but in recent times there are some things like set-group-ID
and sticky
that have given us octals with 4 places like 1775
. Is it possible to represent every possible permission in octal format? If it is not then I'd better understand why bash's ls
command doesn't seem to have this format.