I came across a piece of code where chmod permissions are getting mapped to an integer.

33204 // -rw-rw-r--
36863 // -rwsrwsrwt
36855 // -rwsrwSrwt
36799 // -rwSrwsrwt
36351 // -rwsrwsrwx
36343 // -rwsrwSrwx

How are these permissions mapped to an integer number?

I am trying to find what permissions these numbers 33261, 41453 map to? I looked at various links, but I could find one that converts permissions into a number. Can someone help me with the conversion? Thanks in advance!


They only make "sense" in octal. Here's the first line using one of my programs to convert:

$ hex 33204
33204: 33204 0100664 0x81b4 text "\201\264" utf8 \350\206\264

The 0100664 means it's a regular file with read/write (user), read/write (group) and read-only (other). The chmod manual pages should mention this, but the first bit (the S_IFREG value) is not mentioned — even by POSIX — as often as the other flags. Here's an example from a header:

#define S_IFMT  00170000
#define S_IFSOCK 0140000
#define S_IFLNK  0120000
#define S_IFREG  0100000
#define S_IFBLK  0060000
#define S_IFDIR  0040000
#define S_IFCHR  0020000
#define S_IFIFO  0010000
#define S_ISUID  0004000
#define S_ISGID  0002000
#define S_ISVTX  0001000

Further reading:

  • Thanks! From a numerical value is there an easy way to get the corresponding permission too? – SyncMaster Jul 20 '17 at 0:35
  • yes - but I don't offhand know of a standalone program to use as an example. – Thomas Dickey Jul 20 '17 at 0:53

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.