Managing Packages with apt (Debian/Ubuntu)

Managing Packages with apt

apt is the package manager for Debian-based Linux distributions including Ubuntu, Debian, and Linux Mint.

Update Package Lists

apt update

Downloads the latest package lists from repositories. Run this before installing anything.

Upgrade Installed Packages

apt upgrade -y          # Upgrade packages, keep existing configs
apt full-upgrade -y     # Also handles dependency changes (may remove packages)

Install a Package

apt install nginx -y

Remove a Package

apt remove nginx         # Remove but keep config files
apt purge nginx          # Remove including config files

Remove Unused Dependencies

apt autoremove -y

Search for a Package

apt search nginx
apt-cache search php | grep mysql

Show Package Information

apt show nginx

List Installed Packages

apt list --installed
dpkg -l | grep nginx

Clean the Package Cache

apt clean        # Removes all cached package files
apt autoclean    # Removes only outdated cached packages

Add a PPA (Personal Package Archive)

add-apt-repository ppa:ondrej/php -y
apt update
apt install php8.2 -y

Hold a Package (Prevent Upgrades)

apt-mark hold nginx
apt-mark unhold nginx
  • 0 Users Found This Useful
Was this answer helpful?

Related Articles

Managing Users and Groups

Managing Users and Groups on Linux Proper user management is essential for server security. Avoid...

Managing Services with systemctl

Managing Services with systemctl systemctl is the standard tool for managing services on modern...

Monitoring Server Resources

Monitoring Server Resources Keeping an eye on your server's resource usage helps you identify...

Scheduling Tasks with Cron

Scheduling Tasks with Cron Cron allows you to schedule commands to run automatically at set...

Installing and Configuring Nginx

Installing and Configuring Nginx Nginx is a high-performance web server and reverse proxy widely...