UnderHost
Knowledgebase Docs

Linux Package Management: Install, Update, Remove Software

Master Linux package management: apt/apt-get (Debian/Ubuntu), yum/dnf (CentOS/RHEL). Install updates, remove packages, manage dependencies safely.

On this page

Package managers are essential Linux tools that install, update, and remove software. They handle dependencies automatically, making system maintenance straightforward. UnderHost VPS and Dedicated servers use package managers to manage all software—from web servers (Nginx, Apache) to databases (MySQL, PostgreSQL) to development tools (Git, Node.js, Python).

What is Package Management?

Without package managers: You'd manually download each software's source code, compile it, handle all dependencies yourself—extremely tedious and error-prone.

With package managers: One command installs software, all dependencies, and integration into your system.

Two main systems on UnderHost:

  • Debian/Ubuntu: Uses apt (Advanced Package Tool)
  • CentOS/RHEL: Uses yum or newer dnf

Check your OS: cat /etc/os-release

Debian/Ubuntu (apt/apt-get)

apt (Newer, recommended)

# Update package lists (check for new versions)
apt update

# Upgrade installed packages to new versions
apt upgrade

# Full system upgrade (may remove/install packages to resolve conflicts)
apt full-upgrade

# Install a package
apt install packagename

# Remove a package
apt remove packagename

# Remove package and config files
apt purge packagename

# Search for a package
apt search packagename

# Show package info
apt show packagename

apt-get (Older, still works)

apt-get update
apt-get upgrade
apt-get install packagename
apt-get remove packagename

Difference: apt is user-friendly, shows progress bars. apt-get is older, more verbose. Both do the same thing; use apt on modern systems.

CentOS/RHEL (yum/dnf)

dnf (Newer, recommended for RHEL 8+)

# Update package lists
dnf check-update

# Upgrade all packages
dnf upgrade

# Install a package
dnf install packagename

# Remove a package
dnf remove packagename

# Search for a package
dnf search packagename

# Show package info
dnf info packagename

yum (Older, still used on CentOS 7)

yum check-update
yum update
yum install packagename
yum remove packagename

Installing Packages

Basic installation:

# Install single package
apt install nginx

# Install multiple packages at once
apt install nginx postgresql git nodejs

# Install from specific repository version
apt install nginx=1.20.0-1

Common packages to install:

  • curl: apt install curl - HTTP client tool
  • git: apt install git - Version control
  • htop: apt install htop - System monitoring
  • wget: apt install wget - Download files
  • unzip: apt install unzip - Extract ZIP files

After installing: Service may auto-start or need manual start:

systemctl start nginx
systemctl enable nginx  # Auto-start on boot

Updating System

Keep your system secure with regular updates:

# Step 1: Update package lists
apt update

# Step 2: Upgrade packages
apt upgrade

# Step 3: (Optional) Full upgrade for major changes
apt full-upgrade

# Step 4: Clean up old package files
apt autoclean  # Remove cached install files
apt autoremove # Remove unused dependencies

Schedule automatic updates (on Debian/Ubuntu):

apt install unattended-upgrades
dpkg-reconfigure -plow unattended-upgrades

This automatically applies security updates nightly.

Removing Packages

Remove unwanted packages:

# Remove package (keeps config files)
apt remove packagename

# Remove package and config
apt purge packagename

# Remove package not needed by other packages
apt autoremove

# Clean package cache
apt clean

Important difference:

  • remove: Software gone, settings kept (can reinstall cleanly)
  • purge: Software AND settings gone (complete removal)

Managing Dependencies

Package managers automatically handle dependencies. Example:

# Installing Python also installs required libraries
apt install python3

# If a package needs an older library version, apt handles it
apt install legacy-app

# Show dependencies for a package
apt depends packagename

Dependency conflicts (rare): Sometimes two packages need conflicting versions. Solutions:

  1. Use containers (Docker) for isolated environments
  2. Use virtual environments (Python venv)
  3. Choose alternative packages

Best Practices & Safety

  • Update regularly: Run apt update && apt upgrade weekly
  • Backup before major upgrades: Full system upgrade can occasionally break things
  • Read output carefully: Pay attention to what packages will be installed/removed
  • Don't force old versions: If a package conflicts, there's usually a reason
  • Use official repositories: Only add PPAs from trusted sources
  • Test in staging first: Test major updates on staging VPS before production
  • Keep security patches current: Never skip security updates

Add third-party repository (if needed):

# Add repository
add-apt-repository ppa:username/ppa-name

# Update to include new repository
apt update

# Now install from new repository
apt install packagename

⚠️ Caution: Only add PPAs from trusted sources. Bad PPAs can compromise your system.

Always backup before full system upgrades

While apt upgrade is usually safe, apt full-upgrade can occasionally remove packages you need. Backup first (see our backup strategy guide).

Related: Command line basics | Kernel updates | Security hardening

Was this article helpful?

Need server management?

Let UnderHost help with server hardening, updates, troubleshooting, monitoring, and ongoing Linux administration.

Related articles

Back to Server Management