APT command in detail.

When you go through this post, please write every command in the terminal and execute it. Then look at the result. It will help you a lot to remember the command.


APT stands for Advanced Packaging Tool. It is a package manager for the Debian base system. APT package manager download and install packages from online repositories. It only uses one file for download and installs. In that file has a listing of all of the online locations it gets it to package from. This filename is sources.list located on /etc/apt/sources.list.

With APT, we can search, install, remove, update, and upgrade packages. We will learn together how to do these actions. We want to install a package.
To install, let's first open the terminal. There are many ways to open the terminal.
1. Go to the launcher and search for the terminal.
2. Right-click on the window and select the open terminal.
3. Press the shortcut ctrl + alt + t.
You can choose whatever you prefer.


Say, We want to install GIMP. GIMP is a photo editor for Ubuntu. First, we have to make sure GIMP is present in the online repositories. We can not do anything if it is not present in the online repositories. To makes sure that, We can search for a package using apt.

apt search gimp

This will give us everything about gimp packages. This is tedious to do finding the gimp package from a bunch of packages.


To make it easy we can do this.

apt list gimp

It will give us what we are looking for. This makes sure GIMP is present in the repository.

apt list is so handy when you want to know about installed packages and upgradable packages. For install packages:

apt list --installed

For upgradable packages:

apt list --upgradeable


Now we want to know details about GIMP. To know that enter

apt show gimp

Now we will get lots of information about gimp such as version, installed size, etc.


Now we want to install it. To install it enter

sudo apt install gimp

Note: When you enter a command with sudo It will always prompt for the password.

This command will ask for your permission, to give permission press y. Then it will take some time to install it.
Now we want to verify its really installed or not. We can verify by going into the launcher by searching “gimp”.


We can install packages. But now we want to remove it. How can I do that? To do so enter

sudo apt remove gimp

This command will ask for your permission, to give permission press y. Then it will take some time to remove it. But it may be left some configuration file on our system. To know that configuration file enter the previous command with --purgeoption.

sudo apt remove --purge gimp

If you look at the output of the command you will find like this line.

The following packages were automatically installed and are no longer required.

After that line, list of some packages that are no longer needed. But still in our system. Why we want to take them even they are no longer needed. If you look at the output closely, the output recommends us how to remove them.

Clean up

To remove that unnecessary thing enter.

sudo apt autoremove

Again, this command will ask for your permission. Then it will take some time to remove the unnecessary configuration files. As well as, this command will clean up your system by removing every unnecessary configuration file of any removed packages.

To remove a package, we use 3 different commands. We can remove it with one command. To do that just enter

sudo apt purge gimp

It will save us from extra effort and energy.


As days pass every software releases its new version. So we need to make sure our system and every software are up to date. To make up to date, we can tell APT to update our system and software by entering this command.

sudo apt update

This command will go to the repository and get an updated list of packages that are available. And synchronize the updated repository to the cache file on our system.

Now we can check which packages are ready to be upgraded using one of our previous commands.

apt list --upgradable

This will give us a list of packages that are upgradable.


sudo apt updatecommand just synchronizes the cache file not install the newer version of packages. To install those updated packages Enter

sudo apt upgrade

It will upgrade(install newer version) all of the packages according to the cache file. We can do this in one step instead of two.

sudo apt update && sudo apt upgrade

There I want to show you one last thing about apt.

sudo apt full-upgrade

Now the question arises what is the difference between “upgrade” and “full upgrade”?
The difference is “upgrade” will never remove a package or install new packages that not in our system. On the other hand, ``full-upgrade`` will upgrade what it considers most important packages on the system and it may remove those packages if determine that are no longer needed.

Note: You must be performed “update” first then “upgrade”. Without that, it will do nothing.

In a nutshell:

  1. ctrl + alt + t the keyboard shortcut for opening terminal.
  2. apt search packagename for searching packages.
  3. apt list packagename for getting a specific package that is looking for.
  4. apt list --installed for getting installed packages in the system.
  5. apt list --upgradable for getting upgradable packages in the system.
  6. apt show packagenameto know details about packages.
  7. sudo apt install packagenamefor installing new packages.
  8. sudo apt remove packagenamefor removing packages.
  9. sudo apt purge packagename for removing packages and extra config files that are no longer needed.
  10. sudo apt autoremove for clean up unnecessary config files or packages from your system.
  11. sudo apt update packagename && sudo apt upgrade packagename for updating and upgrading a single package.
  12. sudo apt update && sudo apt upgrade for updating the cache file and upgrading packages that are available.

Congrats! Now you know about what APT command does. I really appreciate your time and your energy to read my article. If you think it is valuable then share it with your friends. And if I am wrong please let me know to fix myself.




MERN Stack Developer | Book lover | Also a Procrastinator

Love podcasts or audiobooks? Learn on the go with our new app.

Recommended from Medium

AWS Lambda monitoring mechanism using SNS

How to Implement SSO in 7 Easy Steps

Earned Value Analysis in Time Tracking Software?

Solution — Brownie testing for reverted transactions does not work with pytest.raises()

Web scrapping Using Python

An Introduction to How to Study Computer Programming

Libra ❤ Docker

One thousand lines of code later @ MakeHarvard

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store
Akibur Rahman (Akib)

Akibur Rahman (Akib)

MERN Stack Developer | Book lover | Also a Procrastinator

More from Medium

Git and Github — TechnoPals

Computer Networking 6: Proxy Server

Handy MySQL Commands - I

Docker inside a Docker Container 💻