Server Setup

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

by , , revisited on


We have by far the largest RPM repository with dynamic stable NGINX modules and VMODs for Varnish 4.1 and 6.0 LTS. If you want to install NGINX, Varnish, and lots of useful modules for them, this is your one-stop repository to get all performance-related software.
You have to maintain an active subscription in order to be able to use the repository!

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

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.

  1. Dr Kevorkian

    thanks but I am still getting “sudo: apt-get: command not found” after it seems to have installed.

    Reply
    • Danila Vershinin

      If you want it to work with sudo, then it should be placed to /usr/bin/apt-get.

      Alternatively, become the root user first, e.g. sudo -i.

      Reply
  2. Silviu

    Why are you leading people to think they can get apt-get on CentOS? Is it even possible. Yours it’s just a bash script that call yum. Very misleading.

    Reply
    • Danila Vershinin

      Just read it carefully, where it says “But I hope this is going to help you move towards CentOS and learn the commands for managing packages”. It emits “yum” commands to help learning. Of course it’s not a real “apt” and never can be. It is a learning/convenience script.

      Reply
  3. Entspannungswandler

    Linux **: why no common install tool for all these distributions WHY????

    Reply
    • Danila Vershinin

      Well, indeed. Linux distros were the first ones to introduce the niceties of packaged installs but the package managers (and package formats) vary from distro to distro.
      And even Linus Torvalds himself, I believe, had to say that those packaging differences really suck.

      Reply

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.

%d bloggers like this: