🖥️rpm

➡️This is a command-line reference manual for commands and command combinations that you don’t use often enough to remember it. This cheatsheet explains the rpm command with important options and switches using examples.

▁ ▂ ▃ ▄ ꧁ 🔴☠ COMMANDLINE-KUNGFU WITH CHEATSHEETS ☠🔴꧂▅ ▃ ▂ ▁

#                ██████╗ ██████╗ ███╗   ███╗
#                ██╔══██╗██╔══██╗████╗ ████║
#                ██████╔╝██████╔╝██╔████╔██║
#                ██╔══██╗██╔═══╝ ██║╚██╔╝██║
#                ██║  ██║██║     ██║ ╚═╝ ██║
#                ╚═╝  ╚═╝╚═╝     ╚═╝     ╚═╝
                                           
                                           
                                           
# To install a package:
rpm -ivh <rpm>

# To remove a package:
rpm -e <package>

# To remove a package, but not its dependencies
rpm -e --nodeps <package>

# To find what package installs a file:
rpm -qf </path/to/file>

# To find what files are installed by a package:
rpm -ql <package>
rpm -qpl <rpm>

# To find what packages require a package or file:
rpm -q --whatrequires <package>
rpm -q --whatrequires <file>

# To list all installed packages:
rpm -qa

# To find a pkg's dependencies
rpm -i --test <package>

# Display checksum against source
rpm -K <package>

# Verify a package
rpm -V <package>

#==============================#
# CMD rpm Packetverwaltung
#==============================##==============================#
rpm -qa --filesbypkg | grep " /var/log/"
# List all rpm packaged files in /var/log by what rpm they belong to.

rpm -qa | grep -e http -e php -e mariadb | xargs rpm -V
# Quickly check the integrity of the "AMP" stack on rpm based systems.

rpm -qa --queryformat "%{NAME} %{INSTALLTIME:date}\n" | grep "Nov 2015"
# In RPM, determine which packages where installed in Nov 2015.

rpm -qf $( which lspci )
# Pass the output of which (showing path to lspci) into rpm -qf, which tells you the pkg.

rpm -qa --last | head
# Show the last 10 packages installed on an RPM based host. 

rpm -qa --last | tail
# Show the last 10 packages installed on an RPM based host.

rpm -qa | grep -e http -e php -e mariadb | xargs rpm -V
# Quickly check the integrity of the "AMP" stack on rpm based systems.

rpm --dbpath=/oldserverbackup/var/lib/rpm -q perl-Date-Manip
# Specify an alternate rpm database path using --dbpath.

rpm -q -p -filesbypkg Myfile.rpm  
# List content of rpm file

rpmdir="$(grep "^%_topdir" /usr/lib/rpm/macros | sed -e s#"^.*%{getenv:HOME}"#"${HOME}"#g -e s#"^.*%{_usrsrc}"#"/usr/src"#g)";
# Get the correct RPM Build directory

rpm -qa --queryformat "%-47{NAME} %{PACKAGER}\n" 
# Generate list of installed RPM names(left align) and their packager in formated columns.

# Check when package was installed/updated -> Though technically it’s not one of the yum tips but rather a RPM one but none the less, it’s pretty useful & comes handy at times. We can check when a package has been installed or when its was last update by running the following command,
rpm -qa –last

# To know when a particular package has been installed, execute the following command,
rpm -q package_name –last

rpm -qa --last | head 
# Show the last 10 packages installed on an RPM based host.

# Print the 16 most recent RPM packages installed in newest to oldest order
rpm -qa --last | head -n 16

rpm -qa --queryformat "%10{SIZE} %{NAME}\n" | grep -Ev "(kernel|glibc|perl$|python-libs$|coreutils|hwdata$|glib2|grub2$|yum$|binutils$)" | sort -rn | head -100 
# Show the largest #rpm packages on the system, omitting *some* of the critical ones

#Print the 16 most recent RPM packages installed in newest to oldest order
rpm -qa --last | head -n 16

rpm -qa --queryformat '%{INSTALLTIME} %{name}-%{version}-%{release}\n' | sort -k 1,1 -rn | nl | head -16 | awk '{printf("%3d %s %s\n", $1,strftime("%c",$2),$3)}'

rpm -qa --queryformat '%{INSTALLTIME} %{name}-%{version}-%{release}\n' | sort -k 1,1 -rn | nl | head -16 | awk '{printf("%3d %s %s\n", $1,strftime("%c",$2),$3)}'
# Print the 16 most recent RPM packages installed in newest to oldest order
# Display a list of the 16 most recently installed RPM packages with newest first.
  1 Wed 12 Sep 2018 15:41:27 BST google-chrome-stable-69.0.3497.92-1
  2 Fri 07 Sep 2018 19:00:03 BST qrencode-3.4.4-3.mga5
  3 Fri 07 Sep 2018 19:00:03 BST lib64qrencode3-3.4.4-3.mga5
  4 Mon 03 Sep 2018 15:40:12 BST lib64mariadb18-10.0.36-1.mga5
  5 Tue 24 Jul 2018 09:31:50 BST thunderbird-en_GB-52.9.1-1.mga5
  6 Tue 24 Jul 2018 09:31:50 BST rootcerts-java-20180411.00-1.mga5
  7 Tue 24 Jul 2018 09:31:50 BST rootcerts-20180411.00-1.mga5
  8 Tue 24 Jul 2018 09:31:49 BST thunderbird-52.9.1-1.mga5
  9 Tue 24 Jul 2018 09:31:46 BST nss-3.28.6-1.4.mga5
 10 Tue 24 Jul 2018 09:31:46 BST lib64nss3-3.28.6-1.4.mga5
 11 Tue 24 Jul 2018 09:31:46 BST lib64nspr4-4.19-1.mga5
 12 Sat 21 Jul 2018 18:43:41 BST xclip-0.12-7.mga5
 13 Fri 13 Jul 2018 10:39:35 BST lib64pathplan4-2.38.0-10.1.mga5
 14 Fri 13 Jul 2018 10:39:35 BST lib64gvc6-2.38.0-10.1.mga5
 15 Fri 13 Jul 2018 10:39:35 BST lib64cgraph6-2.38.0-10.1.mga5
 16 Fri 13 Jul 2018 10:39:35 BST lib64cdt5-2.38.0-10.1.mga5

rpm -qa | sed 's/^\(.*\)-\([^-]\{1,\}\)-\([^-]\{1,\}\)$/\1 \2 \3/' | sort | column -t
# Extract rpm package name, version and release using some fancy sed regex
# This command could seem pretty pointless especially when you can get the same result more easily using the rpm builtin queryformat, like: rpm -qa --qf "%{NAME} %{VERSION} %{RELEASE}.%{ARCH}\n" | sort | column -t but nonetheless I've learned that sometimes it can be quite interesting trying to explore alternative ways to accomplish the same task (as Perl folks like to say: There's more than one way to do it!) Show Sample Output:
        # [root@docker ~]# rpm -qa | sed 's/^\(.*\)-\([^-]\{1,\}\)-\([^-]\{1,\}\)$/\1 \2 \3/' | sort | column -t
        # acl                            2.2.51        14.el7.x86_64
        # aic94xx-firmware               30            6.el7.noarch
        # alsa-firmware                  1.0.28        2.el7.noarch
        # alsa-lib                       1.1.6         2.el7.x86_64
        # alsa-tools-firmware            1.1.0         1.el7.x86_64
        # atop                           2.3.0         8.el7.x86_64
        # audit                          2.8.4         4.el7.x86_64
        # audit-libs                     2.8.4         4.el7.x86_64
        # audit-libs-python              2.8.4         4.el7.x86_64
        # authconfig                     6.2.8         30.el7.x86_64
        # basesystem                     10.0          7.el7.centos.noarch
        # bash                           4.2.46        31.el7.x86_64
        # bash-completion                2.1           6.el7.noarch
        # bc                             1.06.95       13.el7.x86_64
        # bind-libs                      9.9.4         73.el7_6.x86_64
        # bind-libs-lite                 9.9.4         73.el7_6.x86_64
        # bind-license                   9.9.4         73.el7_6.noarch
        # bind-utils                     9.9.4         73.el7_6.x86_64
        # binutils                       2.27          34.base.el7.x86_64
        # [... snip ...]

 rpm -ql coreutils | egrep '\.gz' | xargs -L1 zfgrep -A1 'SH NAME' | sort -u
# Find primes w/ PCRE. - PrimeDay

rpm -qa --last | head 
# Show the last 10 packages installed on an RPM based host.

#==============================##==============================#
# CMD RPM						       #
#==============================##==============================#
░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░

  █║▌│║█║▌★ KALI ★ PARROT ★ DEBIAN 🔴 PENTESTING ★ HACKING ★ █║▌│║█║▌

              ██╗ ██╗ ██████╗  ██████╗ ██╗  ██╗███████╗██████╗
             ████████╗██╔══██╗██╔═══██╗╚██╗██╔╝██╔════╝██╔══██╗
             ╚██╔═██╔╝██║  ██║██║   ██║ ╚███╔╝ █████╗  ██║  ██║
             ████████╗██║  ██║██║   ██║ ██╔██╗ ██╔══╝  ██║  ██║
             ╚██╔═██╔╝██████╔╝╚██████╔╝██╔╝ ██╗███████╗██████╔╝
              ╚═╝ ╚═╝ ╚═════╝  ╚═════╝ ╚═╝  ╚═╝╚══════╝╚═════╝

               █║▌│║█║▌ WITH COMMANDLINE-KUNGFU POWER █║▌│║█║▌

░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░