# 📦 Managing Packages with `rpm` on RHEL/CentOS The `rpm` command (RPM Package Manager) is the **low-level package management tool** used on **Red Hat-based** systems such as RHEL, CentOS, Fedora, and others. Unlike `yum`, `rpm` does not resolve dependencies automatically and is best used for advanced or manual package management. Below are the core `rpm` commands categorized and explained. --- ## 📥 1. Installing Packages ### `rpm -i ` ### `rpm --install ` Installs a new `.rpm` package file. This command will **fail if the package's dependencies are not already installed**. ```bash rpm -i ``` or ```bash rpm --install ``` > 💡 Tip: Use `yum localinstall` or `dnf install` instead for dependency resolution. --- ## 🔄 2. Upgrading Packages ### `rpm -U ` ### `rpm --upgrade ` Upgrades an existing package if it is already installed. If the package is not already present, this command will install it. ```bash rpm -U ``` or ```bash rpm --upgrade ``` --- ## ❌ 3. Removing Packages ### `rpm -e ` ### `rpm --erase ` Removes a package from the system by name (not the filename). Note that this command also does **not resolve dependencies**, so it may break things if you're not careful. ```bash rpm -e ``` or ```bash rpm --erase ``` > ⚠️ Caution: Always check what depends on a package before removing it. --- ## 🔍 4. Querying Packages ### `rpm -q ` Query whether a package is installed, and show its version. ```bash rpm -q ``` --- ### `rpm -qa` List **all installed packages**. ```bash rpm -qa ``` --- ### `rpm -qi ` Displays detailed **information** about a specific installed package. ```bash rpm -qi ``` --- ### `rpm -ql ` Lists all files installed by a package. ```bash rpm -ql ``` --- ### `rpm -qf ` Finds out **which package** owns a specific file. ```bash rpm -qf /usr/bin/wget ``` --- ### `rpm -qp ` Query a package file (without installing it) to see its metadata. ```bash rpm -qp ``` --- ### `rpm -K ` Verifies the **signature and integrity** of an RPM package file. ```bash rpm -K ``` --- ## 🛠️ 5. Verifying and Checking ### `rpm -V ` Verifies installed package files against their original metadata (modifications, corruption, etc.). ```bash rpm -V ``` --- ### `rpm --test -i ` Simulates an install without actually installing the package — useful for testing. ```bash rpm --test -i ``` --- ## ✅ Final Notes * `rpm` is a **powerful low-level tool**, but not recommended for resolving dependencies. * For **automated dependency handling**, prefer using `yum` or `dnf`. * Use `rpm` when you need precise control over the package management process or are working with standalone `.rpm` files.