apt
(Advantage package system) command is used for interacting with dpkg
(packaging system used by debian). There is already the dpkg
command to manage .deb
packages. But apt
is a more user-friendly and efficient way.
In simple terms apt
is a command used for installing, deleting and performing other operations on debian based Linux.
You will be using the apt
command mostly with sudo
privileges.
install
followed by package_name
is used with apt
to install a new package.
sudo apt install package_name
sudo apt install g++
This command will install g++ on your system.
remove
followed by package_name
is used with apt
to remove a specific package.
sudo apt remove package_name
sudo apt remove g++
This command will remove g++ from your system.
search
followed by the package_name
used with apt to search a package across all repositories.
apt search package_name
note: sudo not required
apt search g++
Whenever a new package that depends on other packages is installed on the system, the package dependencies will be installed too. When the package is removed, the dependencies will stay on the system. This leftover packages are no longer used by anything else and can be removed.
sudo apt autoremove
This command will remove all unused from your system.
apt
package index is nothing but a database that stores records of available packages that are enabled on your system.
sudo apt update
This command will update the package index on your system.
If you want to install the latest updates for your installed packages you may want to run this command.
sudo apt upgrade
The command doesn't upgrade any packages that require removal of installed packages.
If you want to upgrade a single package, pass the package name:
sudo apt upgrade package_name
This command will upgrade your packages to the latest version.