🎁 New User? Get 20% off your first purchase with code NEWUSER20 Register Now →
Menu

Categories

apt Command

Beginner Package Management man(1)

Package manager for Debian-based distributions

👁 9 views 📅 Updated: Mar 15, 2026
SYNTAX
apt [OPTION]... COMMAND [PACKAGE]...

What Does apt Do?

apt is the primary package management command for Debian, Ubuntu, and their derivatives. It provides a user-friendly interface for installing, removing, upgrading, and searching software packages.

apt combines the most common functions of apt-get and apt-cache with a cleaner interface, progress bars, and color output. It is designed for interactive use in the terminal.

apt manages packages from configured repositories (sources.list), handling dependencies automatically. It downloads, installs, configures, and removes packages and their dependencies.

Options & Flags

OptionDescriptionExample
update Update package lists sudo apt update
upgrade Upgrade installed packages sudo apt upgrade
install Install package(s) sudo apt install nginx
remove Remove a package sudo apt remove nginx
purge Remove package and config files sudo apt purge nginx
search Search for packages apt search redis
show Show package details apt show nginx
autoremove Remove unused dependencies sudo apt autoremove
list --installed List installed packages apt list --installed

Practical Examples

#1 Update and upgrade

Updates package lists and upgrades all packages.
$ sudo apt update && sudo apt upgrade -y

#2 Install package

Installs multiple packages, automatically confirming.
$ sudo apt install nginx php-fpm postgresql -y

#3 Search packages

Searches package names and descriptions.
$ apt search "web server"

#4 Show package info

Shows version, size, dependencies, and description.
$ apt show nginx

#5 Remove and clean

Removes nginx and any orphaned dependencies.
$ sudo apt remove nginx && sudo apt autoremove

#6 List installed

Lists all installed PHP packages.
$ apt list --installed | grep php

#7 Full system upgrade

Complete system update with dependency changes and cleanup.
$ sudo apt update && sudo apt full-upgrade -y && sudo apt autoremove -y

Tips & Best Practices

Always update first: Run sudo apt update before installing packages. Without it, apt may not find the latest versions.
apt vs apt-get: apt is for interactive terminal use (progress bars, colors). apt-get is for scripts (stable output format). Both work.
autoremove regularly: sudo apt autoremove removes orphaned packages. Run it after removing packages to keep the system clean.

Frequently Asked Questions

How do I install software on Ubuntu?
sudo apt update && sudo apt install package_name. Always update first.
How do I update all packages?
sudo apt update && sudo apt upgrade. Use -y flag to auto-confirm.
What is the difference between apt and apt-get?
apt is the modern, user-friendly command. apt-get is the older, scriptable version. Both manage the same packages.

Master Linux with Professional eBooks

Curated IT eBooks covering Linux, DevOps, Cloud, and more

Browse Books →