What is apt?
apt
stands for Advanced Packaging Tool
.
It is a package manager in a Debian based Linux system.
It is used for managing the installation, updating, and removal of software packages.
In Debian based Linux system dpkg
is the packaging system responsible for packing the software for installation.
apt-get acts as a tool that interacts with this packaging system.
apt commands list
List of apt command options
a@ubuntu:/$ apt
autoclean build-dep depends edit-sources
install policy remove showsrc
upgrade autopurge changelog dist-upgrade
full-upgrade list purge search
source autoremove clean download
help moo rdepends show
update
apt help
a@ubuntu:/$ apt help
apt 2.0.4 (amd64)
Usage: apt [options] command
apt is a commandline package manager and provides commands for
searching and managing as well as querying information about packages.
It provides the same functionality as the specialised APT tools,
like apt-get and apt-cache, but enables options more suitable for
interactive use by default.
Most used commands:
list - list packages based on package names
search - search in package descriptions
show - show package details
install - install packages
reinstall - reinstall packages
remove - remove packages
autoremove - Remove all unused packages automatically
update - update list of available packages
upgrade - upgrade the system by installing/upgrading packages
full-upgrade - upgrade the system by removing/installing/upgrading packages
edit-sources - edit the source information file
satisfy - satisfy dependency strings
See apt(8) for more information about the available commands.
Configuration options and syntax is detailed in apt.conf(5).
Information about how to configure sources can be found in sources.list(5).
Package and version choices can be expressed via apt_preferences(5).
Security details are available in apt-secure(8).
This APT has Super Cow Powers.
apt command examples
sudo
command allows you to run programs as another user, by default the root user
List available packages
sudo apt list
sudo apt list --installed
sudo apt list --all-versions
sudo apt list --upgradeable
Search for a package
sudo apt <package_name>
Show information about an installed package
sudo apt show <package_name>
Install or reinstall specific packages
- Install a new package(s), or if package is already installed then upgrade the package to the latest available version
sudo apt install <package_name_1> <package_name_2> <package_name_3>
- Install a new package, but if package is already installed don’t upgrade it
sudo apt install <package_name_1> --no-upgrade
- Install a specific version of a package
sudo apt install <package_name>=<version_number>
- Reinstall a package
sudo apt reinstall <package_name>
Check updates on all available packages
Linux system holds information about available packages in a database. Following command is used to check the new versions for any packages and update the package database.
sudo apt update
Command result -
- Hit: There is no change in package version
- Ign: The package is being ignored.
- Get: There is a new version available. Information about new version will be updated in database.
Upgrade all packages
- Upgrade all packages
sudo apt upgrade
sudo apt upgrade -y
-y flag is used to force the command and skip the yes/no question
- Upgrade all packages along with removal of any packages not required on System anymore
sudo apt full-upgrade
sudo apt full-upgrade -y
- Update and upgrade the packages together
sudo apt full-update && sudo apt full-upgrade -y
Remove installed packages
- Autoremove : Used to clean up the system from packages and libs that are not required any more after updates and upgrades.
sudo apt autoremove
- Remove: Remove a specific package without removing its configuration files.
sudo apt remove <package_name>
- Purge: Remove a package along with all its configuration files. No traces of package are left behind.
sudo apt purge <package_name>