Installing, updating and removing software on Linux is done with a package manager. The package manager handles software, its dependencies and its updates centrally and securely. This guide covers Debian/Ubuntu's apt and the RHEL family's dnf as the foundation of keeping a server up to date and secure.

Related reading: Essential Linux server commands · Connecting to a server with SSH

What Is a Package Manager?

A package manager is a tool that installs and updates software as compiled packages, together with their dependencies. Unlike individual installers on Windows, on Linux you can install a piece of software and all the components it needs with a single command.

Packages are downloaded from central sources called repositories, verified by the distribution. So software installed with a package manager is both trustworthy and receives updates from a single point.

Which Distribution Uses Which Tool?

DistributionPackage ManagerPackage Format
Ubuntu, Debianapt.deb
Rocky, AlmaLinux, RHELdnf.rpm
Fedoradnf.rpm

Package Management with apt (Debian/Ubuntu)

On Debian-based systems, all daily operations are done with apt:

# Update the repository list (required before installing)
sudo apt update

# Upgrade installed packages to the latest version
sudo apt upgrade

# Install a new package
sudo apt install nginx

# Remove a package (use purge to also delete configuration)
sudo apt remove nginx
sudo apt purge nginx

Package Management with dnf (RHEL/Rocky/Alma)

On the RHEL family the same operations are done with dnf; the logic is almost identical:

# Update installed packages
sudo dnf update

# Install a new package
sudo dnf install nginx

# Remove a package
sudo dnf remove nginx

# Search for a package
dnf search nginx

Keeping the Server Up to Date

Package updates bring not just new features but, most often, security patches. Regular updating is the most basic and cheapest step of server security.

Tip
On production servers, back up critical data before updating and, where possible, try it in a test environment first. But do not delay security patches — closing known vulnerabilities is the priority.

Repository Management

Some software is not in the default repositories; you need to add the vendor's own repository. When adding a third-party repository, use only trusted sources — a repository gains the authority to install software on your system. To clean up unneeded packages and cache, you can use apt autoremove / dnf autoremove.

Frequently Asked Questions

What is the difference between apt update and apt upgrade?

apt update refreshes the repository list — it learns which versions are available. apt upgrade actually upgrades the packages to the new version. You run update first, then upgrade.

Should I use apt or apt-get?

For daily use apt is preferred; it gives more readable output. apt-get still works and may be preferred in scripts due to its stable interface.

Why use packages instead of compiling software from source?

Packages receive security updates automatically, manage dependencies and can be removed cleanly. Compiling from source only makes sense when no package exists or special configuration is needed.

An Easy-to-Maintain Server

Keep your server up to date and secure with KEYDAL VPS; install any software with full root access. Explore KEYDAL hosting

WhatsApp