Different distros, different tools — but the same two ideas: refresh the list, then install or upgrade.
apt (Ubuntu / Debian) #
sudo apt update # refresh the list of what's available
sudo apt install nginx
sudo apt upgrade # actually install the upgrades
The distinction people mix up:
apt update does not upgrade anything — it just refreshes the package index. apt upgrade is the step that actually installs newer versions.yum / dnf (RHEL / CentOS) #
sudo yum install nginx
sudo yum update
Modern RHEL-based systems commonly use dnf, though you’ll still run into yum often. The exact commands vary a bit by distro and version — the concepts (refresh → install/upgrade) stay the same everywhere.
Decoding a full command #
sudo apt install git
│ │ │ └── the package
│ │ └──────── the operation
│ └────────────── the package manager
└──────────────────── run with elevated privileges