634
The apt (Advanced Package Tool) is used in Debian-based Linux distributions like Ubuntu, Debian, and Linux Mint to install, update, and manage software packages.
Updating & Upgrading Packages
| Command | Description |
|---|---|
| sudo apt update | Update package lists (without upgrading). |
| sudo apt upgrade | Upgrade all installed packages. |
| sudo apt full-upgrade | Upgrade with dependency changes. |
| sudo apt autoremove | Remove unnecessary packages. |
| sudo apt clean | Clear downloaded package cache. |
| sudo apt autoclean | Remove old, unused package files. |
Example: Update and Upgrade All Packages
sudo apt update && sudo apt upgrade -y
Installing & Removing Packages
| Command | Description |
|---|---|
| sudo apt install <package> | Install a package. |
| sudo apt install -y <package> | Install without confirmation. |
| sudo apt remove <package> | Remove a package (but keep config files). |
| sudo apt purge <package> | Remove a package and its config files. |
| sudo apt reinstall <package> | Reinstall a package. |
Example: Install and Remove VLC
sudo apt install vlc sudo apt remove vlc
Searching for Packages
| Command | Description |
|---|---|
| apt search <package> | Search for a package. |
| apt show <package> | Show package details. |
| apt list –installed | List installed packages. |
| apt list –upgradable | List packages with available updates. |
Example: Search for a Web Server
apt search apache
Managing Repositories
| Command | Description |
|---|---|
| sudo add-apt-repository ppa:<repo> | Add a PPA (Personal Package Archive). |
| sudo apt update | Update after adding a new repository. |
| sudo add-apt-repository –remove ppa:<repo> | Remove a PPA. |
Example: Add the Latest VLC PPA
sudo add-apt-repository ppa:videolan/stable-daily sudo apt update sudo apt install vlc
Managing Dependencies
| Command | Description |
|---|---|
| apt depends <package> | Show dependencies of a package. |
| apt rdepends <package> | Show reverse dependencies (which packages need it). |
Example: Check Dependencies of curl
apt depends curl
Package Sources & Information
| Command | Description |
|---|---|
| cat /etc/apt/sources.list | View main repository list. |
| ls /etc/apt/sources.list.d/ | View additional repo lists. |
| `dpkg -l | grep ` |
Example: View Installed Version of Git
dpkg -l | grep git
Fixing Common Issues
| Command | Description |
|---|---|
| sudo apt –fix-broken install | Fix broken dependencies. |
| sudo dpkg –configure -a | Fix partially installed packages. |
Example: Fix Broken Packages
sudo apt --fix-broken install
Summary
| Feature | Command Example |
|---|---|
| Update Package Lists | sudo apt update |
| Upgrade Installed Packages | sudo apt upgrade |
| Install a Package | sudo apt install package-name |
| Remove a Package | sudo apt remove package-name |
| Search for a Package | apt search package-name |
| List Installed Packages | apt list –installed |
| Fix Broken Dependencies | sudo apt –fix-broken install |
This Linux apt Cheat Sheet helps you efficiently install, update, and manage packages in Debian-based systems
