# The .repo file for dnf, yum and zypper

**CloudRepo Team** November 27, 2026 7 min read

Serving developers since 2016 Founder-run, no venture capital MFA, SSO and audit log on every plan

**Every feature on every plan, with unlimited users.** 14 days free. No credit card required.

[Start free trial](https://www.cloudrepo.io/signup)

Starting at $99/month billed annually.

By default, `dnf` reads its global configuration from `/etc/dnf/dnf.conf` and loads all `*.repo` files under `/etc/yum.repos.d`, where repository files are typically kept and take precedence over the global file. Each `.repo` file uses INI format: a unique repository ID in square brackets, followed by `name=value` options on separate lines, with a `baseurl`, `metalink` or `mirrorlist` option as the minimum. This guide covers the options inside a yum repo file, how to add and list repositories with `dnf`, `dnf5` and `zypper`, and how to point a host at a CloudRepo yum proxy.

## Anatomy of a .repo file

A `.repo` file starts with a section name in square brackets, such as `[your-repo]`. That section name is the repository ID reference and should be unique across configuration files. Below the header, each option sits on its own line in `name=value` form, and the minimal repository configuration needs `baseurl`, `metalink` or `mirrorlist` alongside the repository ID.

The table below lists the core options and defaults from the [DNF Configuration Reference](https://dnf.readthedocs.io/en/latest/conf_ref.html).

| Option          | What it sets                                                                                                            | Default           |
| --------------- | ----------------------------------------------------------------------------------------------------------------------- | ----------------- |
| `name`          | A human-readable name for the repository.                                                                               | The repository ID |
| `baseurl`       | A list of URLs for the repository, tried in the listed order (equivalent to yum’s `failovermethod=priority` behaviour). | `[]`              |
| `enabled`       | Whether to include this repository as a package source.                                                                 | `True`            |
| `gpgcheck`      | Whether to perform a GPG signature check on packages found in this repository.                                          | `False`           |
| `gpgkey`        | URLs of GPG key files that can be used for signing metadata and packages of this repository.                            | Empty             |
| `repo_gpgcheck` | Whether to perform a GPG signature check on this repository’s metadata.                                                 | `False`           |
| `username`      | The username to use for connecting to a repository with basic HTTP authentication.                                      | Empty             |
| `password`      | The password to use for connecting to a repository with basic HTTP authentication.                                      | Empty             |

Two defaults are worth noting in the reference. First, `enabled` defaults to `True`, so a repository is included as a package source unless you disable it. Second, `gpgcheck` and `repo_gpgcheck` both default to `False`.

## Add a repository with config-manager

You can drop a `.repo` file into `/etc/yum.repos.d` by hand, or use `config-manager` to write it for you. The `dnf config-manager` add repo command changed between dnf 4 and dnf5.

In dnf 4, `dnf config-manager [options] <section>...` takes `--add-repo=URL` to add and enable a repository from a file or URL (see the [dnf-plugins-core config-manager reference](https://dnf-plugins-core.readthedocs.io/en/latest/config_manager.html)).

To download a `.repo` file and store it in `repodir`:

```plaintext
dnf config-manager --add-repo http://example.com/some/additional.repo
```

To create a new `.repo` file with a URL as `baseurl` and enable it:

```plaintext
dnf config-manager --add-repo http://example.com/different/repo
```

In dnf5, the subcommand is `addrepo` (see the [dnf5 config-manager manual](https://dnf5.readthedocs.io/en/latest/dnf5_plugins/config-manager.8.html)). Passing `--from-repofile=...` adds a repository configuration file from a URL or local path and copies the file without changes. If the destination filename is missing the `.repo` extension, dnf5 adds it, and it writes the file into the first path in `reposdir`, which defaults to `/etc/yum.repos.d`:

```plaintext
dnf5 config-manager addrepo --from-repofile=http://example.com/some/additional.repo
```

To define a repository with options instead of an existing file, use `--set=REPO_OPTION=VALUE`. At least one of `--set=baseurl=<URL>`, `--set=mirrorlist=<URL>` or `--set=metalink=<URL>` must be set to a non-empty URL:

```plaintext
dnf5 config-manager addrepo --set=baseurl=http://example.com/different/repo
```

That command creates a new `.repo` file with `http://example.com/different/repo` as `baseurl` and enables it. dnf5 generates the repository ID and target file name from `baseurl`.

## List the repositories a host uses

If you need a RHEL repository list command, or want to see which repositories a host with `dnf` currently reads, dnf 4 and dnf5 each have their own command.

In dnf 4, `dnf [options] repolist [--enabled|--disabled|--all]` lists enabled, disabled or all known repositories depending on the flag (see the [DNF Command Reference](https://dnf.readthedocs.io/en/latest/command_ref.html)). With no flag, it lists all enabled repositories:

```plaintext
dnf repolist
```

In dnf5, the form is `dnf5 repo <subcommand> [options] [<repo-spec>...]` (see the [dnf5 repo manual](https://dnf5.readthedocs.io/en/latest/commands/repo.8.html)). Run `list` to list available repositories:

```plaintext
dnf5 repo list
```

## A repository behind a login

In DNF, a repository that uses basic HTTP authentication takes `username` and `password` lines in its `.repo` file. Both options are empty by default.

As a worked example, here is CloudRepo’s `.repo` file for `dnf`. Save it as root at `/etc/yum.repos.d/your-repo.repo`. First make the file, readable by root alone:

**Terminal**

```bash
sudo install -m 600 /dev/null /etc/yum.repos.d/your-repo.repo
```

Then save these lines in it, as root:

`/etc/yum.repos.d/your-repo.repo`

```ini
[your-repo]
name=your-repo (CloudRepo)
baseurl=https://your-org.mycloudrepo.io/repositories/your-repo
username=you@example.com
password=YOUR_REPOSITORY_TOKEN
enabled=1
gpgcheck=1
```

Set `username` to the email address of the account that created the [repository token](https://www.cloudrepo.io/docs/authenticate/repository-tokens.html). If the distribution’s own `.repo` file includes a `gpgkey=` line, copy it into this file too.

Then install a package. The `-y` flag answers dnf’s prompt, so the command also runs in a script:

**Terminal**

```bash
sudo dnf install -y jq
```

## zypper

On systems that use `zypper`, `zypper addrepo` (shorthand `ar`) adds a repository from a URI with an alias, or from a URI pointing to a `.repo` file (see the [zypper(8) manual page](https://manpages.opensuse.org/Tumbleweed/zypper/zypper.8.en.html)).

Newly added repositories have auto-refresh disabled by default, except repositories imported from a `.repo` file, which have auto-refresh enabled. To enable auto-refresh on a new repository, use `addrepo -f` or pass `--refresh` to `modifyrepo`. Because `addrepo` does not automatically refresh the new repository, run `zypper refresh` (shorthand `ref`) afterward; with no repository named, it refreshes all enabled repositories.

To list all defined repositories, or show detailed information about specific repositories passed as arguments, use `zypper repos` (shorthand `lr`), in the form `repos (lr) [options] [repo]...`:

```plaintext
zypper repos
```

As a worked example, here is CloudRepo’s `zypper` setup. Save the credentials file as root at `/etc/zypp/credentials.d/cloudrepo-your-repo`. First make the file, readable by root alone:

**Terminal**

```bash
sudo install -m 600 /dev/null /etc/zypp/credentials.d/cloudrepo-your-repo
```

Then save these lines in it, as root:

`/etc/zypp/credentials.d/cloudrepo-your-repo`

```txt
username=you@example.com
password=YOUR_REPOSITORY_TOKEN
```

Now add the repository, refresh and install a package:

**Terminal**

```bash
sudo zypper addrepo --refresh 'https://your-org.mycloudrepo.io/repositories/your-repo?credentials=cloudrepo-your-repo' your-repo
sudo zypper refresh
sudo zypper -n install jq
```

The `credentials=cloudrepo-your-repo` part names the credentials file, and `zypper` reads the token from it. Using one file per repository lets a host keep a token for each CloudRepo repository it reads. The `-n` flag answers zypper’s prompt for you.

## Copy a whole repository, or proxy it

If you want a local copy of a remote repository, `dnf reposync [options]` (in the [reposync plugin docs](https://dnf-plugins-core.readthedocs.io/en/latest/reposync.html)) makes local copies of remote repositories and skips packages that are already in the local directory. A CloudRepo yum proxy takes another approach: it puts a Linux distribution’s repository behind your organization’s CloudRepo host, so `zypper` on openSUSE and `dnf` on Rocky Linux install packages through it. Point `dnf` or `zypper` at a yum proxy, and your Linux servers install their packages through CloudRepo with no mirror for you to run.

## Where CloudRepo helps

CloudRepo’s [yum proxy repositories](https://www.cloudrepo.io/yum) are in early access. A yum proxy puts a Linux distribution’s repository behind your organization’s CloudRepo host so `zypper` on openSUSE and `dnf` on Rocky Linux install packages through it.

You create a yum proxy in the admin portal by picking `yum` as the Format and `Proxy` as the Kind, choosing the host it reads from, and typing the folder on that host that holds `repodata/`, for example `/distribution/leap/15.6/repo/oss`. One yum proxy reads one repository.

A yum proxy can read from these hosts:

- `download.opensuse.org` (openSUSE Leap, Tumbleweed and the openSUSE Build Service)
- `dl.rockylinux.org` (Rocky Linux)
- `dl.fedoraproject.org/pub/epel` (EPEL)
- `download.postgresql.org/pub/repos/yum` (PostgreSQL’s PGDG yum repositories)

For EPEL 9 on Rocky Linux 9, the [EPEL 9 walkthrough](https://www.cloudrepo.io/docs/consume/yum.html#install-epel-packages-on-rocky-linux-9) covers every step in order, and `dnf` gets EPEL’s key through your Rocky Linux 9 extras proxy so the host never has to reach a public mirror. You can also create a yum proxy of PostgreSQL’s own PGDG repositories and install PostgreSQL through CloudRepo with `dnf`.

Every CloudRepo plan includes unlimited repositories and users, with no per-seat fees. [Hosted yum repositories](https://www.cloudrepo.io/yum#hosted-rpms) are in early access too: your team uploads the RPMs it builds, and `dnf` and `zypper` install them.

More: [CloudRepo yum and RPM repository proxy](https://www.cloudrepo.io/yum), [Pull Linux packages with zypper and dnf](https://www.cloudrepo.io/docs/consume/yum.html), [Host your own RPMs with dnf and zypper](https://www.cloudrepo.io/docs/consume/yum-hosted.html), [Repository tokens](https://www.cloudrepo.io/docs/authenticate/repository-tokens.html), [All client guides](https://www.cloudrepo.io/guides).

## Every feature on every plan, with unlimited users

[Start free trial](https://www.cloudrepo.io/signup)

14 days free. No credit card required.

Starting at $99/month billed annually.

![Chris Shellenbarger, founder of CloudRepo](https://www.cloudrepo.io/_astro/chris-headshot-150.DWO5wLdz.jpg)

**Founder-run since 2016, with no venture capital.** A real person answers within one business day. Usually it's me.

Chris, founder of CloudRepo

[Book time with Chris](https://www.cloudrepo.io/meet)

## More guides

- [How to point npm at a private registry with .npmrc 4 min](https://www.cloudrepo.io/guides/npmrc-private-registry)
- [Docker pull-through cache: four ways to set one up 4 min](https://www.cloudrepo.io/guides/docker-pull-through-cache)
- [docker login to a private registry from a laptop, CI and Kubernetes 4 min](https://www.cloudrepo.io/guides/docker-login-private-registry)
- [pip.conf, index-url and extra-index-url: install from a private index safely 4 min](https://www.cloudrepo.io/guides/pip-conf-index-url)
- [Maven settings.xml mirrors: send every build through one repository 4 min](https://www.cloudrepo.io/guides/maven-settings-xml-mirror)
- [GOPROXY, GOPRIVATE and GONOSUMDB: what to set for private modules and a proxy 8 min](https://www.cloudrepo.io/guides/goproxy-goprivate)
- [nuget.config for a private feed 8 min](https://www.cloudrepo.io/guides/nuget-config-private-feed)
- [sources.list and signed-by: the current way to add an apt repository 6 min](https://www.cloudrepo.io/guides/apt-sources-list)

---

The page: https://www.cloudrepo.io/guides/dnf-yum-repo-file
