Understanding RPM Tags in Linux


All rpm package comes with certain tags and can be used for better formatting and fetching the output as required by a Admin or day to day basis.


If we wanna see all the tags we can use

rpm --querytags

Some examples for using these tags are as below

1) Finding only name and version we can use

rpm -qa --queryformat "%{NAME} %{VERSION}\n"

2) Make output in better format in above command

rpm -qa --queryformat "%-30{NAME} %-10{VERSION}\n"

3) Find file names in a package with better format

rpm -ql --queryformat "%{FILENAMES}\n" bash

4) Find file names with size

rpm -ql --queryformat "[%{FILENAMES} %{FILESIZES}\n]" zip

5) Find package install date 

rpm -q --queryformat "%{NAME} %{INSTALLTIME:date}\n" zip

6) File files in a package and the permissions 

rpm -q --queryformat "%{FILEMODES:perms} %{FILENAMES}\n" zip