In this tutorial, we will give you an overview of package management utilities on Ubuntu and Debian, Centos, Fedora, and FreeBSD. Once you install, say, Apache and Nginx, PHP, a MySQL database, all these systems start behaving similarly. The main difference is located in the tools for package management and that is how most newcomers to VPS boxes decide which server to run their sites and applications on.
and for each of these will show how to
If you want to try out the commands, you will need
Windows users download their applications from web sites and each app is then responsible for the upgrades and security patches. Linux is different: all applications wait in so-called repositories to be downloaded and installed. Programs that download and install the packages are called package managers and each Linux distribution will have its own repository and the corresponding package manager. For more popular systems, such as Ubuntu, there are repositories for each major version, say, 14.04, 16.04 and so on. The so-called backport repositories may exist as well, when a newer version of the package, say from Ubuntu version 16.04, is ported “back” to the repository for Ubuntu version 14.04.
Unlike Windows users, on Linux you would not even care which version is installed. The package manager would choose the proper version and see to the rest of the process. Some software companies deliver installation files directly, on Debian for example, but there are lower level commands to handle such cases as well.
Package manager can search the repository so that you can see whether the package you want to install is there. It is also possible to test what would change in the system if you installed a package, which may be of vital importance in certain cases.
The same package manager can remove the installed package from system cache, and can also deinstall the app, completely. If there is a newer version in the repository then in the VPS, the package can be upgraded on the run.
For Debian-like systems, including Ubuntu, the basic high level package manager is called apt. Its lower level counterpart, for dealing with particular files is called dpkg. File type is .deb.
apt is a relatively new service, and gained prominence with Ubuntu 16.04. The name of the package manager that was used previously is apt-get. To make things even more confusing, the set of tools that Debian uses to manage packages is called APT — which is not the apt that we are talking here about.
apt was introduced to simplify package management for normal users. It has more default values and is easier to use than apt-get. apt-get, however, is not going anywhere and can still be used without problems. In this tutorial, we are going to use apt only.
The command to read documentation about apt is
apt help
You will have the most popular commands at a glance:
Package managers read files from the repository into the systems cache. The command is:
sudo apt update
Run that on Debian box. Dozens of lines of output will be produced, ending with
Notice it says there are 3 packages to be upgraded. Run
apt list --upgradable
to see the complete list.
Running the same upgrade command on Ubuntu 19.0 will produce a different outcome:
Under Ubuntu, there will be 65 packages to upgrade.
The entire server version will be updated with:
sudo apt upgrade
The command
sudo apt full-upgrade
will perform full upgrade, which means that the conflicting package dependencies will be upgraded to the newest version, removing older or unused dependencies at the same time.
Following along recipes for installation of software for your VPS, you will frequently see the following line:
sudo apt update && sudo apt upgrade
which both updates and upgrades the server. That way, you are guaranteed to have the latest version of software for the installation.
You can search for the software to install:
sudo apt search packageName
The result may not be that usable, as it may consist of dozens of lines of available packages. You may want to copy the contents of the terminal window into a text editor and there search for the package name.
To install software, the command is:
sudo apt install packageName
For example, running
sudo apt install perl
on Debian let me install one new module for programmins language perl, while on Ubuntu nothing needed to be installed as
perl is already the newest version (5.28.1-6).
apt cannot install software from a URL, but the lower level package RPM can. Installing from the repositories is always safer, though.
To remove a package:
sudo apt remove packageName
apt will remove unused dependencies, but in case some still remain, here’s another command:
sudo apt autoremove
How to list all installed packages:
apt list --installed
yum is the package manager for Centos, a security oriented version of Red Hat Linux. File format is .rpm. yum installs or upgrades any package dependencies, which is the main benefit from using it. yum wil download packages from the official repositories, but you can also set up your own repositories on systems that do not have Internet access.
Run
yum help
The first screen lists all commands:
The second screen shows available parameters for yum:
The update command of Yum both upgrades and updates the system:
sudo yum update
Even if your server installation is just one day old, as is the case here, there will be something new to upgrade and install:
It will ask you for approval, once or twice; answer Y if you want the installation to proceed.
WARNING: For longer transactions, it may appear that the terminal is dead (nothing happens in its window). Be patient and wait it out. Otherwise, when another transaction is set in motion, Centos will ask you to finish the previous transaction first. Or, you can clean up with the command such as:
yum-complete-transaction --cleanup-only
To search for an installable package:
sudo yum search packageName
Install a package with the following command:
sudo yum install packageName
NOTE: yum will ALWAYS install the latest version of the kernel.
Remove a package with:
sudo yum remove packageName
yum includes three commands for removing the packages:
While Centos is a free version of Red Hat Linux, Fedora is like a laboratory for research and development for those two systems. As of Fedora version 22, DNF has replaced yum as the official package manager and it is likely that one day the same will happen on Centos. DNF should serve as the improved version of yum so the commands will be similar.
With DNF, maintaining groups of machines is made easier, so you do not need to manually update each one using rpm. It also
The command is:
dnf help
Here is a list of the main commands that it supports:
And this is the list of plugins and a partial list of optional arguments:
To update and upgrade all software:
sudo dnf update
As usual, answer with Y when asked whether you want to proceed with the installation.
There also is a command
dnf check-update
but you do not need to do this as DNF updates its cache automatically before performing transactions.
Search for an installable package:
sudo dnf search packageName
To install a package:
sudo dnf install packageName
To remove a package:
sudo dnf remove packageName
The autoremove command will search across the system and remove unused dependencies:
sudo dnf autoremove
This is the warning it sent me:
so be sure to always add the name of the package you want autoremoved:
sudo dbf autoremove packageName
Here is a comparison between apt and DNF commands:
Ubuntu command | Fedora command |
apt update | dnf check-update |
apt upgrade | dnf upgrade |
apt dist-upgrade | dnf system-upgrade |
apt install | dnf install |
apt remove | dnf remove |
apt purge | N/A |
apt-cache search | dnf search |
FreeBSD has two ways of installing software:
The main difference is that pkg will install only the binary packages.
The command is
pkg help
freebsd-update fetch install
pkg update && pkg upgrade
Press Y when asked whether to install.
Search for a package:
pkg search packagename
Install a package:
pkg install packagename
Here is what installing nginx looks like:
List installed packages:
pkg info
Upgrade from remote repository:
pkg upgrade
Delete an installed package:
pkg delete packageName
Check for missing dependencies:
pkg check -d -a
Remove unneeded dependencies:
pkg autoremove
List non-automatic packages:
pkg query -e '%a = 0' %o
List automatic packages:
pkg query -e '%a = 1' %o
Change a package from automatic to non-automatic, which will prevent autoremove from removing it:
pkg set -A 0 packageName
Change a package from non-automatic to automatic, which will make autoremove it be removed once nothing depends on it:
pkg set -A 1 packageName
Audit installed packages for security advisories:
pkg audit
And here is the result:
The audit command goes to the vulnerability database for FreeBSD and reads from there. Here is what it’s readable form looks like:
We should now wait for the upgraded version to appear and then use the upgrade command to patch it.
Dusko Savic is a technical writer and programmer.
The post Package Management Walkthrough: apt, yum, dnf, pkg appeared first on Low End Box.
In this article, we will see how to Install Google Cloud BigQuery Python client library…
Nov 15,2024 Wallpaper Contest for Xfce 4.20 open for voting The submission phase for the…
MicroCloud 2.1.0 LTS is now available, expanding the number of Canonical infrastructure solutions with a…
Canonical is thrilled to be joining forces with Dell Technologies at the upcoming Dell Technologies…
In today’s massive private mobile network (PMN) market, one of the most common approaches to…
Welcome to the Ubuntu Weekly Newsletter, Issue 865 for the week of November 3 –…