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: