apt command with examples

apt (Advanced Package Tool) is the most frequently used command in Debian-based Linux distribution system. It provides command-line tool to search, install, remove, update or to manage packages which are downloaded from different software repositories. apt command ensures the package dependencies effectively while installing, upgrading and downgrading the packages. When you use apt command you will see the progress bar and also get to know the number of packages can be updated. In this post, we are going to see usage of apt commands with examples.

Prerequisites:
1. root or sudo privileges for a user.
2. internet access to download packages
3. Debian/Ubuntu running instance
1. Updating Package Index
This command basically pull the latest changes of packages from the repository and update database index. This is to keep Debian/Ubuntu system up to date. 
$ sudo apt update
2. Upgrading the packages with available version
Run below command, once the package databases is updated. It is now time to upgrade all the up-gradable packages on the system with the latest version available. 
Note: you need to update the package first to execute upgrade command below.
$ sudo apt upgrade
3. To list the packages which can be upgraded on the system.
List the up-gradable packages details before upgrading packages. 
$ sudo apt list –upgradable

4. apt full-upgrade
Full-upgrade performs the function of upgrade but will remove currently installed packages if this is needed to upgrade the system as a whole.
$ sudo apt full-upgrade  

5. If you know the package name, following command to install a New Packages.

$ sudo apt install vlc

Install multiple packages.
$ sudo apt install <package1> <package2>
6. To list all the available, installed and upgrade-able packages.
$ sudo apt list | more

To list a single package
$ apt list | grep vlc
To list installed packages only.
$ sudo apt list –installed
7. Show package information
Below command shows the information of given package including dependencies, installation, size, source and description of the packages.

8. Edit source information file /etc/apt/sources.list

will prompt to choose editor (nano or vi) to edit a file
$ sudo apt edit-sources
9. How to search packages?
$ sudo apt search vlc
10. To remove package called VLC
$ sudo apt remove vlc
Note: Will remove all files expect config files.
Use purge option to remove package and all config files.
$ sudo apt purge vlc
Also read: Usage of dpkg command in Debian based Linux
Conclusion: In this tutorial, apt commands with examples for Debian and Ubuntu New users. To know more about apt command, type “man apt” from command prompt. Big thanks for reading all the way to the end. Please share it with Your Friends & Help Someone… and also like our facebook page. Let me hear your thoughts in the comments below!

Leave a Comment