> ## Documentation Index
> Fetch the complete documentation index at: https://notes.kodekloud.com/llms.txt
> Use this file to discover all available pages before exploring further.

# Use RPM and YUM Package Management Zypper

> This article explains how to use Zypper for package management in SUSE Linux and openSUSE, covering installation, removal, and repository management.

Zypper is the powerful command-line package manager for SUSE Linux and openSUSE, providing functionality similar to YUM and APT. It enables you to install, update, and remove packages, automatically resolving dependencies. Because Zypper relies on up-to-date repository metadata, it’s best practice to refresh before performing searches or installations.

<Callout icon="lightbulb" color="#1CB2FE">
  You need `sudo` privileges to run Zypper commands that modify the system.\
  Always refresh metadata to ensure you get the latest package versions.
</Callout>

***

## Refreshing Package Metadata

Before you search or install packages, update metadata from all enabled repositories:

```bash theme={null}
sudo zypper refresh
```

This fetches the latest repository data so Zypper can see available package versions.

***

## Searching for Packages

Use the `se` (search) command to find packages by name or keyword:

```bash theme={null}
sudo zypper se gnumeric
```

Sample output:

```text theme={null}
Loading repository data...
Reading installed packages...
S | Name           | Summary                         | Type
--+----------------+---------------------------------+--------
  | gnumeric       | Spreadsheet application         | package
  | gnumeric-devel | Development files for Gnumeric  | package
  | gnumeric-doc   | Documentation for Gnumeric      | package
  | gnumeric-lang  | Translations for Gnumeric       | package
```

***

## Listing Installed Packages

To list **all** installed packages:

```bash theme={null}
sudo zypper se -i
```

To check if a specific package (e.g., `firefox`) is installed:

```bash theme={null}
sudo zypper se -i firefox
```

Example when Firefox is installed:

```text theme={null}
Loading repository data...
Reading installed packages...
S | Name                           | Summary                     | Type
--+--------------------------------+-----------------------------+--------
i | MozillaFirefox                 | Mozilla Firefox Web Browser | package
  | MozillaFirefox-branding-openSUSE | Branding files for openSUSE | package
  | MozillaFirefox-translations-common | Common translations     | package
```

***

## Installing Packages

### From Repositories

Install a package from enabled repositories with the `in` (install) command:

```bash theme={null}
sudo zypper in unrar
```

Interactive example:

```text theme={null}
Resolving package dependencies...
The following NEW package is going to be installed:
  unrar

1 new package to install.
Overall download size: 141.2 KiB. After the operation, additional 301.6 KiB will be used.
Continue? [y/n/v/...? shows all options] (y): y
Retrieving package unrar-5.7.5-lp151.1.1.x86_64 ...................................[done]
(1/1) Installing: unrar-5.7.5-lp151.1.1.x86_64 ..........................................[done]
```

### From a Local RPM

To install an RPM file stored on your machine:

```bash theme={null}
sudo zypper in /path/to/package.rpm
```

Zypper will attempt to resolve dependencies against your enabled repositories.

***

## Removing Packages

Use the `rm` (remove) command to uninstall a package and any packages that depend on it:

```bash theme={null}
sudo zypper rm unrar
```

Example:

```text theme={null}
Resolving package dependencies...
The following package is going to be REMOVED:
  unrar

1 package to remove.
After the operation, 301.6 KiB will be freed.
Continue? [y/n/v/...? shows all options] (y): y
(1/1) Removing unrar-5.7.5-lp151.1.1.x86_64 ..........................................[done]
```

<Callout icon="triangle-alert" color="#FF6B6B">
  Removing packages may also uninstall dependencies required by other applications. Double-check the list before confirming.
</Callout>

***

## Managing Software Repositories

### Listing Repositories

Display all configured repositories and their status:

```bash theme={null}
sudo zypper repos
```

Sample output:

```text theme={null}
# | Alias                      | Name                                | Enabled | GPG Check | Refresh
--+----------------------------+-------------------------------------+---------+-----------+--------
1 | openSUSE-Leap-15.1-1       | openSUSE-Leap-15.1-1               | No      | ----      | ----
2 | repo-non-oss               | Non-OSS Repository                  | Yes     | (r) Yes   | Yes
3 | repo-oss                   | Main Repository                     | Yes     | (r) Yes   | Yes
4 | repo-source                | Source Repository                   | No      | ----      | ----
```

Enabled = **Yes** means active; **No** means disabled.

### Enabling, Disabling, and Auto-Refresh

| Command                             | Description                     |
| ----------------------------------- | ------------------------------- |
| `zypper modifyrepo -d <repo-alias>` | Disable a repository            |
| `zypper modifyrepo -e <repo-alias>` | Enable a repository             |
| `zypper modifyrepo -f <repo-alias>` | Enable auto-refresh for a repo  |
| `zypper modifyrepo -F <repo-alias>` | Disable auto-refresh for a repo |

Example:

```bash theme={null}
# Disable
sudo zypper modifyrepo -d repo-non-oss

# Enable
sudo zypper modifyrepo -e repo-non-oss

# Enable auto-refresh
sudo zypper modifyrepo -f repo-non-oss

# Disable auto-refresh
sudo zypper modifyrepo -F repo-non-oss
```

### Adding and Removing Repositories

* **Add a new repository**:

  ```bash theme={null}
  sudo zypper addrepo http://packman.inode.at/suse/openSUSE-Leap_15.1/packman packman
  ```

  Sample output:

  ```text theme={null}
  Adding repository 'packman' ...........................[done]
  Repository 'packman' successfully added
  URI         : http://packman.inode.at/suse/openSUSE-Leap_15.1/
  Enabled     : Yes
  GPG Check   : Yes
  Autorefresh : No
  Priority    : 99 (default)
  ```

* **Remove a repository**:

  ```bash theme={null}
  sudo zypper removerepo packman
  ```

  Sample output:

  ```text theme={null}
  Removing repository 'packman' ........................[done]
  Repository 'packman' has been removed.
  ```

***

## Links and References

* [Zypper User Guide](https://doc.opensuse.org/projects/libzypp/doc/zypper/)
* [openSUSE Documentation](https://en.opensuse.org/Portal:Zypper)
* [SUSE Linux Enterprise Server](https://www.suse.com/products/server/)

<CardGroup>
  <Card title="Watch Video" icon="video" cta="Learn more" href="https://learn.kodekloud.com/user/courses/linux-professional-institute-lpic-1-exam-101/module/78ca0fa8-2083-408a-bf8a-2775b09fbf1d/lesson/ae5d58db-cf95-4eec-9da4-e879559d4af8" />
</CardGroup>
