Skip to content

Instantly share code, notes, and snippets.

@juanje
Last active October 9, 2020 18:57
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save juanje/c33ae8aa113cac644d89328999b7d6e6 to your computer and use it in GitHub Desktop.
Save juanje/c33ae8aa113cac644d89328999b7d6e6 to your computer and use it in GitHub Desktop.
RPM tips & tricks
# Just a place to write down notes for old time Debian/Ubuntu user
# that has just moved into Fedora/RedHat world
# Show which package provides the file '/bin/ls'
# Similar to 'dpkg -S /bin/ls'
$ rpm -qf /bin/ls
coreutils-8.5-7.fc14.i686
# The same but showing only the package name (without version)
$ rpm -qf /bin/ls --queryformat '%{NAME}\n'
coreutils
# Search for installed package
$ rpm -q BitTorrent
BitTorrent-5.2.2-1.noarch
# List files from installed package
$ rpm -ql BitTorrent
/usr/bin/bittorrent
/usr/bin/bittorrent-console
...
# See the package's scripts (postinstall, preuninstall, postunnstall...)
$ rpm -q --scripts httpd
postinstall scriptlet (using /bin/sh):
if [ $1 -eq 1 ] && [ -x /usr/bin/systemctl ]; then
# Initial installation
/usr/bin/systemctl --no-reload preset httpd.service htcacheclean.service httpd.socket || :
fi
preuninstall scriptlet (using /bin/sh):
if [ $1 -eq 0 ] && [ -x /usr/bin/systemctl ]; then
# Package removal, not upgrade
/usr/bin/systemctl --no-reload disable --now httpd.service htcacheclean.service httpd.socket || :
fi
...
# List all installed packages (dpkg -l)
$ rpm -qa
# List the last installed packages
$ rpm -qa --last
# Rebuild (editing) a RPM file
$ rpmrebuild -enp package.rpm
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment