Ubuntu Terminal: How to View the Current CHMOD Octal Value of a File or Folder Software & Sites 21 MAR 2012

Linux (and thus Ubuntu) file access permissions often get in your way if you aren’t a power user, but if you have played around with the Ubuntu terminal for long enough, you should by now be aware of the magical CHMOD command and the way in which it can alter file and folder permissions.

The most common way of using the chmod command to change file access permissions is by specifying a three digit octal value which then gets interpreted as user access values. But say now you want to view the existing octal access values of a file?

Well, this is a nifty little tip to list the current numeric CHMOD values for all files and folders in the current directory.

Open up a terminal (Ctrl+Alt+T) and run:

stat -c '%A %a %n' *

Using the useful stat function (run ‘man stat’ to learn more), we’ve used the access rights in human readable form, access rights in octal, and finally the file name itself formatting options to achieve our helpful display.


Related Posts:

About Craig Lotter

South African software architect and developer at Touchwork. Husband to a cupcake baker and father to two little girls. I don't have time for myself any more.