apt (Debian & Ubuntu)
apt installs, updates and removes software on Debian-based systems.
Syntax
sudo apt [update|upgrade|install|remove] [package]You rarely download software manually on Linux. Instead a package manager fetches programs and their dependencies from trusted online repositories. On Ubuntu and Debian that tool is apt.
The core commands
sudo apt update— refresh the list of available packages. Run this first.sudo apt upgrade— install newer versions of what you have.sudo apt install git— install a package.sudo apt remove git— uninstall it.apt search word— find packages by keyword.
update only refreshes the catalogue; upgrade actually installs the newer versions.
Example
# Refresh the catalogue, then upgrade everything
sudo apt update
sudo apt upgrade
# Install a package
sudo apt install curl
# Remove it and its unused dependencies
sudo apt remove curl
sudo apt autoremoveWhen to use it
- A developer installs Node.js on an Ubuntu server with 'sudo apt install nodejs' without manually downloading a binary.
- A sysadmin runs 'sudo apt upgrade' weekly in a cron job to keep all installed packages patched against security vulnerabilities.
- A DevOps engineer uses 'apt list --installed' to audit which packages are present on a server before taking a snapshot.
More examples
Install and update packages
Shows the standard workflow: update index, install a package, then upgrade all packages non-interactively.
# Update the package index first
sudo apt update
# Install a package
sudo apt install nginx
# Upgrade all installed packages
sudo apt upgrade -ySearch and remove packages
Demonstrates searching, inspecting, and removing packages with the difference between remove and purge.
# Search for packages matching a name
apt search 'postgresql'
# Show details about a package
apt show nginx
# Remove package (keep config files)
sudo apt remove nginx
# Remove package AND config files
sudo apt purge nginxClean up unused packages
Shows maintenance commands for reclaiming disk space and auditing installed software.
# Remove automatically installed deps no longer needed
sudo apt autoremove
# Clear the downloaded package cache
sudo apt clean
# List installed packages
apt list --installed 2>/dev/null | grep nginx
Discussion