# rpm

## rpm

The `rpm` command is a package management tool for managing RPM (Red Hat Package Manager) packages. It is used in Red Hat-based distributions, such as Fedora, CentOS, and RHEL (Red Hat Enterprise Linux). The `rpm` command allows users to install, query, verify, update, and remove RPM packages.

#### Basic Usage

**Installing a Package**

To install an RPM package, use:

```sh
sudo rpm -i package_name.rpm
```

Options:

* `-i`: Install the specified package.

**Removing a Package**

To remove an installed package, use:

```sh
sudo rpm -e package_name
```

Options:

* `-e`: Erase (remove) the specified package.

**Upgrading a Package**

To upgrade an existing package or install it if it's not already installed, use:

```sh
sudo rpm -U package_name.rpm
```

Options:

* `-U`: Upgrade the specified package.

**Querying Packages**

To query installed packages or specific package files, use:

```sh
rpm -q package_name
```

Options:

* `-q`: Query the specified package.

Example: To query if a package is installed:

```sh
rpm -q httpd
```

To get detailed information about an installed package:

```sh
rpm -qi package_name
```

Options:

* `-i`: Display package information.

**Listing Files in a Package**

To list files installed by a package, use:

```sh
rpm -ql package_name
```

Options:

* `-l`: List the files in the package.

**Verifying a Package**

To verify the integrity and authenticity of an installed package, use:

```sh
rpm -V package_name
```

Options:

* `-V`: Verify the specified package.

**Importing a GPG Key**

RPM packages can be signed with GPG keys to ensure their integrity. To import a GPG key:

```sh
sudo rpm --import /path/to/RPM-GPG-KEY
```

#### Advanced Usage

**Installing from a Repository**

For installing packages from repositories, you would typically use `yum` or `dnf` (the newer package manager for Fedora and RHEL-based distributions). However, you can combine `rpm` with `yum`/`dnf` if you need to:

```sh
sudo yum install package_name
```

Or with `dnf`:

```sh
sudo dnf install package_name
```

**Force Install/Upgrade**

To forcefully install or upgrade a package, ignoring some dependency issues:

```sh
sudo rpm -ivh --force package_name.rpm
```

Options:

* `--force`: Force the installation or upgrade.
* `-v`: Verbose mode.
* `-h`: Print hash marks as the package archive is unpacked.

**Checking Dependencies**

To check the dependencies of an RPM package:

```sh
rpm -qpR package_name.rpm
```

Options:

* `-p`: Query a package file.
* `-R`: List the requirements (dependencies) of the package.

#### Example Usage

**Installing a Package**

To install a package named `example-1.0-1.x86_64.rpm`:

```sh
sudo rpm -i example-1.0-1.x86_64.rpm
```

**Querying a Package**

To get information about the installed `httpd` package:

```sh
rpm -qi httpd
```

**Listing Files in a Package**

To list all files installed by the `httpd` package:

```sh
rpm -ql httpd
```

**Verifying a Package**

To verify the integrity of the `httpd` package:

```sh
rpm -V httpd
```

#### Conclusion

The `rpm` command is an essential tool for managing software packages on Red Hat-based systems. It provides a comprehensive set of options for installing, querying, verifying, updating, and removing packages. Understanding how to use `rpm` effectively can help you manage your system's software efficiently.

## help

```
```


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://linux-tutorial-cli.gitbook.io/linux-cli-tutorial/txt-files/rpm.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
