14

I want to see what permissions the files within an rpm will "have" after the rpm is installed. But without having to install the rpm.

rogerdpack
  • 62,887
  • 36
  • 269
  • 388

5 Answers5

18

The --dump option to rpm gives you this information (as well as other information).

rpm -qp --dump "$RPM_PACKAGE_FILENAME"
rogerdpack
  • 62,887
  • 36
  • 269
  • 388
Etan Reisner
  • 77,877
  • 8
  • 106
  • 148
  • 1
    Interesting. `rpm --dump -qp packagename.noarch.rpm` gives me lines like `/home/.../filename 694 1440086385 cdc64eac59d2d1400cabb433e1cd11af 0100750 USER USER 0 0 0 X` perhaps one of those is permissions do you think? – rogerdpack Aug 20 '15 at 17:11
  • 1
    Yes, the `0100750` bit there. See the man page for the `--dump` option for what all the fields are. – Etan Reisner Aug 20 '15 at 17:13
10

On CentOS 6 and 7, adding the -l and -v options to -qp seems to be enough:

$ rpm -qpl golang-vet-0-1.0.hgd32b5854c941.el7.x86_64.rpm
/usr/bin/vet
/usr/lib/golang/pkg/tool/linux_amd64/vet
$ rpm -qplv golang-vet-0-1.0.hgd32b5854c941.el7.x86_64.rpm
-rwxr-xr-x    1 root    root                  5764251 Aug 21  2014 /usr/bin/vet
lrwxrwxrwx    1 root    root                       12 Aug 21  2014 /usr/lib/golang/pkg/tool/linux_amd64/vet -> /usr/bin/vet
$ rpm --version
RPM version 4.11.3
muru
  • 4,723
  • 1
  • 34
  • 78
8

Here's a way that shows you permissions "like ls does":

 $ rpm -q --qf "[%-15{=NAME} %-36{FILENAMES} %{FILEMODES:perms}\n]" -p $FILENAME
 FILENAME            /etc/pam.d/sudo                      -rw-r--r--
 FILENAME            /etc/file/name/here                  -rw-r--r--
 ....

ref

rogerdpack
  • 62,887
  • 36
  • 269
  • 388
2

I just use less. ;) It shows the permissions in ls-style form.

In RedHat-based distros, it seems to pass it to rpm -qpivl --changelog (via /usr/bin/lesspipe.sh)

Aaron D. Marasco
  • 6,506
  • 3
  • 26
  • 39
0

NOTE: This is the same solution than provided by muru (Just confirming it also works on MacOS brew install rpm)

Also works on MacOS (rpm installed via brew)

$ rpm --version
RPM version 4.14.0

$ rpm -qvlp <rpm-packagename>
rogerdpack
  • 62,887
  • 36
  • 269
  • 388
huch
  • 675
  • 8
  • 13