APT and dpkg (Debian, Ubuntu)
In short: dpkg installs individual .deb packages. APT is the layer above: it downloads packages from sources, resolves dependencies and updates the system.
In more detail: apt is the user-friendly command line. Older scripts use apt-get and apt-cache. All commands for installing and removing need root rights (sudo).
In detail
sudo apt update # refresh package lists
sudo apt upgrade # update installed packages
sudo apt full-upgrade # also remove/reinstall packages if needed
sudo apt install vlc # install
sudo apt remove vlc # remove (settings stay)
sudo apt purge vlc # remove including settings
sudo apt autoremove # no longer needed dependencies
apt search word # search
apt show vlc # details
dpkg -i file.deb # install a single file
dpkg -l | grep vlc # list installed packages- Configuration:
/etc/apt/sources.listand/etc/apt/sources.list.d/(new:.sourcesfiles in deb822 format). - Keys: packages are signed with GPG keys, stored in
/etc/apt/keyrings. - Pinning versions:
apt-mark hold packageprevents an update. - Broken installation:
sudo apt --fix-broken install. - Lock: the message “Could not get lock” means another package process is running.
See also: Package management on Linux at a glance, Package sources, repositories and PPAs