1

rpm --dump will print file mode in 7-digit octal format:

$ rpm -q --dump rpm | grep -E '/usr/bin/rpmdb|/var/lib/rpm ' | cut -d' ' -f1,5
/usr/bin/rpmdb 0100755
/var/lib/rpm 040755
$

What do all those digits mean? I guess some of it will be related to file type, but can I reproduce the same string given I have an existing file and standard command line tools (+ perl/python, etc. if necessary)?

I've looked at rpm(1), which does not reveal anything (only calls the field "mode"), and stat(1), which only mentions the usual 4-digit mode. Closest I got is this other question about 6-digit format on AIX.

Edit: I just noticed it's sometimes 6 digits; question remains mostly the same, though.

Alois Mahdal
  • 4,440

1 Answers1

6

This is the st_mode field of the stat structure: it encodes both the file type and the mode bits. Do man 2 stat (or perhaps man 7 inode) on a linux system and search for the section entitled "The file type and mode". E.g. 0100755 means "regular file with mode 755" and 040755 means "directory with mode 755".

BTW, the leading 0 means "octal" since these values are so specified in the header files. The number of digits is irrelevant: it's just what is needed to contain the full value.

NickD
  • 2,926