π 2016-May-11 ⬩ βοΈ Ashwin Nanjappa ⬩ π·οΈ chmod, ls, octal, permission ⬩ π Archive
The ls
command shows the access permissions of a file or directory in the symbolic representation using rwx
. Sometimes you may want the view the permissions in octal representation. Sadly ls
has no option to show this.
However, the stat
command shows both the octal and symbolic representations by default amongst the other wealth of details it lists:
$ stat foobar.txt
File: βfoobar.txtβ
Size: 1692 Blocks: 8 IO Block: 4096 regular file
Device: 802h/2050d Inode: 57285082 Links: 1
Access: (0400/-r--------) Uid: ( 1001/ joe) Gid: ( 1001/ joe)
Access: 2016-05-11 15:16:32.884351709 +0800
Modify: 2016-05-11 13:42:04.135990274 +0800
Change: 2016-05-11 15:16:31.872327471 +0800
Birth: -
To get just the permissions in octal representation:
$ stat --format="%a" foobar.txt
400
Tried with: Ubuntu 14.04