The other day I needed the output of a directory on Linux showing the octal file permissions. It got me thinking - exactly how do I achieve this? The obvious solution would be the ls command, but a quick read of its man page suggested it couldn't be achieved that way.
In fact, the answer is with the stat command. The following syntax is required:
stat -c "%a %n" *
The -c flag says use the following format, whilst the format itself is:
%a Access rights in octal
%n File name.
So, a typical example would be:
badzilla@laptop4:/srv/www/htdocs/clean/sites/all/modules/tester> stat -c "%a %n" * 644 tester_admin_input_field.inc 644 tester.info 644 tester.module badzilla@laptop4:/srv/www/htdocs/clean/sites/all/modules/tester>
blog terms
Linux