Package Managers

Dec 26, 2017 22:54 · 344 words · 2 minute read Linux Yum Apt

Common commands for packages managers that I always forget

Yum/RPM

# Query an installed package
rpm -q zsh
# Install a package
yum install -y httpd
# List all installed packages
yum list installed
# Get dependancies of a package
yum deplist zsh
# Download a RPM (might need to install yum-utils)
yumdownloader zsh
# Download the RPM source
yumdownloader --source zsh
# Get info about a package
rpm -qpi zsh-5.4.1-1.fc27.x86_64.rpm
# Install the package
rpm -ivh zsh-5.4.1-1.fc27.x86_64.rpm
# Install package, ignore dependancies
rpm -ivh zsh-5.4.1-1.fc27.x86_64.rpm --nodeps
# Install package force
rpm -ivh zsh-5.4.1-1.fc27.x86_64.rpm --force
# Verify an install
rpm -V zsh
# Remove a package
rpm -e zsh
# Search for a package
yum search zsh
# Extract binaries from rpm
rpm2cpio zsh-5.4.1-1.fc27.x86_64.rpm | cpio -i --make-directories
# Rebuild a source rpm (Should be located in /user/src/distname/RPMS/arch)
rpmbuild --rebuild packagname-version.src.rpm

RPM config file: /usr/lib/rpm/rpmrc, /etc/rpmrc, ~/.rpmrc

Yum files: /etc/yum.conf, /etc/yum.repos.d/

Find additional packages:


Apt/DPKG

# Get information on installed package
dpkg -p zsh
apt-cache show zsh
# List installed packages
apt list --installed
# List installed packages verbose info
dpkg -l
# Show current version and candidate version info
apt-cache policy zsh
# List files associated with packages
dpkg -L tar
# Get info on package
dpkg -I zsh_5.2-5ubuntu1_amd64.deb
# Download a deb file
apt download zsh
# Extract deb
dpkg -x zsh_5.2-5ubuntu1_amd64.deb .
# Install a deb file
dpkg -i zsh_5.2-5ubuntu1_amd64.deb
# Remove a package, leave configs
apt --remove zsh
# Remove a package including configs
apt --purge zsh
# Get information about deb file
dpkg --info zsh_5.2-5ubuntu1_amd64.deb
# Stats on package database
apt-cache stats
# Get dependancies of a package
apt-cache depends zsh
# Get reverse dependancies of a package
apt-cache rdepends perl --installed
# Update info about packages
apt update
# Upgrade packages but use smart conflict resolution
apt dist-upgrade
# Get source of package (dpkg-dev might need to be installed)
apt-get source zsh
# Reconfigure a package
dpkg-reconfigure samba
# Interactive package manager
aptitude

Main sources list: /etc/apt/sources.list

DPKG Configs: /etc/dpkg/dpkg.cfg, ~/.dpkg.cgf

Find Packages: