Ade Malsasa Akbar contact
Senior author, Open Source enthusiast.
Saturday, March 25, 2017 at 23:37


For Ubuntu users switching to Fedora, or vice versa, anyone needs a comparison of both common package manager commands. The goal is the user knows that "dnf install" in Fedora is equal to "apt-get install" in Ubuntu and so on. This article compares common use such as sync, install, remove, upgrade, and repolist; plus config files and further references. Here this article provides that comparison in a simple format.

Subscribe to UbuntuBuzz Telegram Channel https://telegram.me/ubuntubuzz to get article updates directly.


1. Get Repo Index


A "repo index" is a list of all packages available in a distro repository. In other words, it's a "map" listing the details of all packages inside a repo. Ubuntu/Fedora and some distros called this "update" (although it's rather confusing), another ones called this "sync". Anyway, without this, a package manager doesn't know where/what to download.

Ubuntu
$ sudo apt-get update

Fedora
$ sudo dnf check-update


2. Search a Package


User can search for a package after the package manager gets the repo index. For example, you want to know what image editor available on the repo, then just search it.

Ubuntu
$ apt-cache search "image editor"

Fedora
$ dnf -C search "image editor"


3. Show Info of a Package


User can read the detailed info of a package such as name, version, size, description, and so on.

Ubuntu
$ apt-cache show <package_name>

Fedora
$ dnf -C info <package_name>


4. Show Package Location on Repo


User can see in what repo a package belong, at what version, and what status is it (installed/available) in the system.

Ubuntu
$ apt-cache policy <package_name>

Fedora
$ dnf -C list <package_name>

5. Remove a Package


To uninstall package, dnf and apt share the same command 'remove'.

Ubuntu
$ sudo apt-get remove <package_name>

Fedora
$ sudo dnf remove <package_name>


6. Upgrade Installed Packages


User can upgrade all installed packages in one command.


Ubuntu
$ sudo apt-get upgrade

Fedora
$ sudo dnf upgrade --refresh


7. Clean Downloaded Packages


User can delete downloaded packages from package cache directory. This is useful when the cache goes larger and eats your HDD space.

Ubuntu
$ sudo apt-get clean

Fedora
$ sudo dnf clean


8. Download Only, No Install


User can choose not to install, but only download package. APT will download .deb packages, while DNF will download .rpm. The package files downloaded will go to package cache. In Ubuntu, it's /var/cache/apt/archives/ and in Fedora it's /var/cache/dnf/{repo-name}/packages/.

Ubuntu
$ sudo apt-get install --download-only <package_name>

Fedora
$ sudo dnf install --downloadonly <package_name>


9. List Installed Packages


User can see all installed packages (or filter them with grep) on the system. For this case Ubuntu uses DPKG instead of APT. For example, you can start looking all packages have "gnu" on their names.

Ubuntu
$ dpkg -l
$ dpkg -l | grep -i gnu

Fedora
$ dnf -C list
$ dnf -C list | grep -i gnu

10. List All Repos


Ubuntu stores its repo list at /etc/apt/sources.list file, while Fedora stores it at /etc/yum.repos.d/ directory. To reveal each own repo list:

Ubuntu
$ cat /etc/apt/sources.list
$ cat /etc/apt/sources.list.d/*.list

Fedora
$ dnf -C repolist

11. Disable a Repo


User can disable a repo being used in their system.

Ubuntu

Write manually a '#' (hash) character on the beginning of line of a repo address in sources.list. There is no APT command for this.

Fedora
$ sudo dnf repo --disablerepo <repo_name>


Important Files


For both APT and DNF, Ubuntu and Fedora, there are some directories and files important for their package managements. User makes any configuration or store the packages downloaded there.

APT
  • Source repo addresses: /etc/apt/sources.list
  • APT configuration: /etc/apt/apt.conf
  • Repo index files: /var/lib/apt/lists/
  • Downloaded package cache: /var/cache/apt/archives

DNF
  • Source repo addresses: /etc/yum.repos.d/{repo_name}.repo
  • DNF configuration: /etc/dnf/dnf.conf
  • Repo index files: /var/cache/dnf/{repo-name}/repodata/
  • Downloaded package cache: ls /var/cache/dnf/{repo-name}/packages/


References