Site icon GetPageSpeed

How to use apt or apt-get for CentOS/RHEL

Apt-Get in CentOS

As I already manage a CentOS/RHEL YUM repository (and stick to CentOS with a rationale of being more secure), I’m not eager to work with Ubuntu operating system or learn how to package things for it.
Yet many of my clients, for no reason whatsoever, want to stick to Ubuntu, even for clean server setup.

Ubuntu and CentOS are both based on the Linux kernel. The primary difference is with the packaging system being aptitude for Ubuntu and yum for CentOS.
Many folks who already use Ubuntu are not excited to even try CentOS just because it seems entirely different. But that’s not the case. Especially if you can get apt-get working in CentOS.

Install apt-get in CentOS

Install CentOS APT wrapper:

curl https://raw.githubusercontent.com/dvershinin/apt-get-centos/master/apt-get.sh -o /usr/local/bin/apt-get
chmod 0755 /usr/local/bin/apt-get

Use apt-get in CentOS

Now you have the familiar interface for installing packages through apt-get install <package name> 🙂

Obviously, this is just an alias-like wrapper for the native yum package manager in CentOS. But I hope this is going to help you move towards CentOS and learn the commands for managing packages. (when you run apt-get it will tell you the corresponding yum command after installing/removing a package).

Reference

For the basic package management tasks, all package managers are quite similar. You can look at the reference table below.
From this, you can understand, that migrating to CentOS/RHEL and its yum (or dnf, in the newer CentOS/RHEL version) is not something to be afraid of.

You’ll just usually type yum instead of apt. The commands that follow are quite similar, e.g. yum install <package name>.

apt apt-get yum dnf purpose
apt-get install foo apt install foo yum install foo dnf install foo install package foo
apt-get remove foo apt remove foo yum remove foo dnf remove foo remove package foo
apt-get purge apt purge n/a n/a remove package foo with config files
apt-get update apt update yum makecache dnf makecache update repository index
apt-get upgrade apt upgrade yum upgrade dnf upgrade Upgrades all upgradable packages
apt-get autoremove apt autoremove yum autoremove dnf autoremove remove unneeded packages
apt-get dist-upgrade apt full-upgrade yum upgrade dnf upgrade upgrade all packages
apt-cache search foo apt search foo yum search foo dnf search foo search for a package
apt-cache show foo apt show foo yum show foo dnf show foo shows package details

P.s. A new convenience wrapper is planned here, which would help in learning CentOS even faster.

Exit mobile version