quick-docs/modules/ROOT/pages/dnf-vs-apt.adoc

97 lines
3.3 KiB
Text
Raw Normal View History

2023-08-07 06:28:07 +00:00
= DNF and its APT command equivalents on Fedora
2023-08-06 17:45:39 +00:00
Michal Ambroz; Christopher Engelhard ; The Fedora Docs team
:revnumber: F37
:revdate: 2023-02-03
:category: Administration
2023-08-28 21:49:13 +00:00
:tags: How-to, DNF
2023-08-06 17:45:39 +00:00
// Optional free form useful additional information as comment
2020-08-05 23:42:30 +00:00
2020-08-06 00:18:34 +00:00
APT is the package manager/dependency solver for the Debian ecosystem, i.e. it manages `.deb` packages installed by the DPKG program. Fedora software is based on `.rpm` packages, and thus uses DNF, the package manager/dependency solver for the RPM program, instead. This document gives a brief overview of the most common APT commands one might find in tutorials and their DNF equivalents.
2020-08-05 23:42:30 +00:00
== APT vs. DNF commands
.Apt vs DNF commands
|===
| APT command | DNF command | notes
2021-11-27 18:56:13 +00:00
| `apt install`
`apt-get install`
| `dnf install`
| Of course, actual package names may vary. For example, `libc6-dev` on Debian maps to `glibc-devel` in the Fedora universe.
2023-02-08 21:34:02 +00:00
| `apt install --only-upgrade package`
| `dnf update package`
| Updates only already installed package and its dependencies. The `apt install` works for both install and upgrade single package if already installed.
2020-08-05 23:42:30 +00:00
| `apt update`
`apt-get update`
| `dnf check-update`
2021-11-27 18:56:13 +00:00
| This command is rarely needed, as dnf updates its package cache automatically when it is stale. A cache update can be forced by appending `--refresh` to other commands, e.g. `dnf upgrade --refresh`.
2020-08-05 23:42:30 +00:00
| `apt upgrade`
`apt-get upgrade`
| `dnf upgrade`
2021-11-27 18:56:13 +00:00
| Note that while `apt update` does something different, `dnf update` and `dnf upgrade` are synonyms. You can also use the shorter `dnf up`.
2020-08-05 23:42:30 +00:00
| `apt full-upgrade`
`apt-get dist-upgrade`
| `dnf distro-sync` or
`dnf system-upgrade` (see note)
2021-11-27 18:56:13 +00:00
| While `distro-sync` is the most direct functional equivalent, `dnf system-upgrade` should be used to upgrade from one release to another, e.g. from Fedora Linux 34 to 35. This is a multi-step process as described xref:dnf-system-upgrade.adoc[here].
2020-08-05 23:42:30 +00:00
| `apt remove`
`apt-get remove`
| `dnf remove`
|
| `apt purge`
`apt-get purge`
| ---
2021-11-27 18:56:13 +00:00
| Fedora packages don't treat configuration files in the same way as Debian packages, so there is no direct equivalent.
2020-08-05 23:42:30 +00:00
| `apt autoremove`
`apt-get autoremove`
| `dnf autoremove`
2021-11-27 18:56:13 +00:00
| Note that this can occasionally remove packages that you might actually want. Use `dnf mark` to flag packages to keep.
2020-08-05 23:42:30 +00:00
| `apt search`
`apt-cache search`
| `dnf search`
2021-11-27 18:56:13 +00:00
| `dnf repoquery` is useful for advanced searches.
2020-08-05 23:42:30 +00:00
|===
2021-11-27 18:56:13 +00:00
With the exceptions of the distribution upgrade working differently, and DNF updating the cache automatically, the commands are very similar. More info on DNF can be found xref:dnf.adoc[here].
2020-08-05 23:42:30 +00:00
== Why is APT in the Fedora repositories?
WARNING: APT *can not* be used to install packages on Fedora, you *have to use DNF* instead.
2021-11-27 18:56:13 +00:00
The `apt` command on Fedora used to -- until https://fedoraproject.org/wiki/Changes/Move_apt_package_from_RPM_to_DPKG_backend[Fedora 32] -- actually be APT-RPM, which basically mapped normal apt commands so that they worked with Fedora's RPM package management system.
2020-08-05 23:42:30 +00:00
2021-11-27 18:56:13 +00:00
However, APT-RPM is unmaintained, broken, and insecure, and so was dropped in favour of shipping the actual Debian APT software. Since APT exclusively deals with `.deb` packages, the `apt` command can no longer be used to manage Fedora packages. Its purpose is now purely as a tool for people building packages for Debian-based distributions on a Fedora system.
2020-08-05 23:42:30 +00:00