linux · ppc64le · x86_64

linux: find out file permissions numbers

When dealing with file on Linux you eventually will handle file permissions in multiple situations. Although the default permission schema shown by the command ls tends to be more intuitive given its verbosity, using a more simple view based on the permissions number might be faster (if you are familiar with it).

For example, lets take a look at the PHP source code. Click here if you would like to learn how to build PHP from scratch 🙂


[rpsene@centosle php-src]$ ls -la

total 5660
drwxrwxr-x. 20 rpsene rpsene 4096 Mar 28 12:42 .
drwx------. 15 rpsene rpsene 4096 Mar 28 12:40 ..
-rw-rw-r--. 1 rpsene rpsene 82601 Mar 28 12:41 acinclude.m4
-rw-rw-r--. 1 rpsene rpsene 312978 Mar 28 12:41 aclocal.m4
drwxrwxr-x. 2 rpsene rpsene 78 Mar 28 10:50 appveyor
-rw-rw-r--. 1 rpsene rpsene 1487 Mar 28 10:50 .appveyor.yml
drwxr-xr-x. 2 rpsene rpsene 51 Mar 28 12:41 autom4te.cache
drwxrwxr-x. 2 rpsene rpsene 4096 Feb 1 14:47 build
-rwxrwxr-x. 1 rpsene rpsene 772 Feb 1 14:47 buildconf
-rw-rw-r--. 1 rpsene rpsene 334 Jan 26 08:04 buildconf.bat
-rw-rw-r--. 1 rpsene rpsene 0 Mar 28 12:41 buildmk.stamp
-rw-rw-r--. 1 rpsene rpsene 11982 Mar 28 12:41 CODING_STANDARDS
-rw-rw-r--. 1 rpsene rpsene 42938 Jan 26 08:04 config.guess
-rw-rw-r--. 1 rpsene rpsene 837058 Mar 28 12:42 config.log

In order to get a simplified view of the file permissions you can use the command stat, which displays file or file system status (see man stat for details).


[rpsene@centosle php-src]$ stat -c '%a - %n' *

664 - acinclude.m4
664 - aclocal.m4
775 - appveyor
755 - autom4te.cache
775 - build
775 - buildconf
664 - buildconf.bat
664 - buildmk.stamp
664 - CODING_STANDARDS
664 - config.guess
664 - config.log
...

%a access rights in octal

%n file name

You can learn more about permissions here.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s