Archive · Linux

Installing Software: apt on Ubuntu, yum on CentOS

The two package managers you will meet most, side by side.

1 min read

  • Ubuntu 18.04.2 LTS
  • apt 1.6
  • CentOS 7.6
  • yum 3.4

Packages come from signed repositories, which handle dependencies and security updates. Always prefer them over downloading binaries by hand.

Task Ubuntu 18.04 (apt) CentOS 7 (yum)
Refresh package lists sudo apt update automatic
Install sudo apt install nginx sudo yum install nginx
Upgrade everything sudo apt upgrade sudo yum update
Remove sudo apt remove nginx sudo yum remove nginx
Search apt search nginx yum search nginx
Which package owns a file dpkg -S /usr/sbin/nginx rpm -qf /usr/sbin/nginx

On Ubuntu, apt is the friendly front end and apt-get is still the one to use in scripts. On CentOS, nginx lives in the EPEL repository: sudo yum install epel-release first.

Run apt update before apt install, otherwise you may fetch a stale version or hit a 404 on a package that has since been replaced.