One important thing to master under Linux System/Server Administration is package management using different package management tools.
Different Linux distributions install applications in a pre-compiled package that contain binary files, configuration files and also information about the application’s dependencies.
Read Also: Learn 25 ‘apt-get’ and ‘apt-cache’ Command Examples in Debian based Systems
Package management tools help System/Server Administrators in many ways such as:
- Downloading and installing software
- Compile software from source
- Keeping track of all software installed, their updates and upgrades
- Handling dependencies
- and also keeping other information about installed software and many more
In this guide, we are going to look at 15 examples of how to use the new APT (Advanced Package Tool) on your Ubuntu Linux systems.
APT is a command-line based tool that is used for dealing with packages on a Ubuntu based Linux systems. It presents a command line interface to the package management on your system.
1. Installing a Package
You can install a package as follows by specify a single package name or install many packages at once by listing all their names.
$ sudo apt install glances
2. Find Location of Installed Package
The following command will help you to list all the files that are contained in a package called glances (advance Linux monitoring tool).
$ sudo apt content glances
3. Check All Dependencies of a Package
This will help you to display raw information about dependencies of a particular package that you specify.
$ sudo apt depends glances
4. Search for a Package
The search option searches for the given package name and show all the matching packages.
$ sudo apt search apache2
5. View Information About Package
This will help you display information about package or packages, run the command below by specifying all the packages that you want to display information about.
$ sudo apt show firefox
6. Verify a Package for any Broken Dependencies
Sometimes during package installation, you may get errors concerning broken package dependencies, to check that you do not have these problems run the command below with the package name.
$ sudo apt check firefox
7. List Recommended Missing Packages of Given Package
$ sudo apt recommends apache2
8. Check Installed Package Version
The ‘version’ option will show you the installed package version.
$ sudo apt version firefox
9. Update System Packages
This will help you to download a list of packages from different repositories included on your system and updates them when there are new versions of packages and their dependencies.
$ sudo apt update
10. Upgrade System
This helps you to install new versions of all the packages on your system.
$ sudo apt upgrade
11. Remove Unused Packages
When you install a new package on your system, it’s dependencies are also installed and they use some system libraries with other packages. The after removing that particular package, it’s dependencies will remain on the system, therefore to remove them use autoremove as follows:
$ sudo apt autoremove
12. Clean Old Repository of Downloaded Packages
The option ‘clean’ or ‘autoclean’ remove all old local repository of downloaded package files.
$ sudo apt autoclean or $ sudo apt clean
13. Remove Packages with its Configuration Files
When you run apt with remove, it only removes the package files but configuration files remain on the system. Therefore to remove a package and it’s configuration files, you will have to use purge.
$ sudo apt purge glances
14. Install .Deb Package
To install a .deb file, run the command below with the filename as an argument as follows:
$ sudo apt deb atom-amd64.deb
15. Find Help While Using APT
The following command will list you all the options with it’s description on how to use APT on your system.
$ apt help
Always remember that good Linux package management, can help you avoid breaking your system. There are so many other package management tools that you can use in Linux.
You can share with us what you use and your experience with it. I hope the article is helpful and for any additional information, leave a comment in the comment section.
26 thoughts on “15 Examples of How to Use New Advanced Package Tool (APT) in Ubuntu/Debian”
I have a problem with my Debian Installation:
I can’t write anything after the password:
The cursor stays still and I can not write
Please can you help me?
That is how it should be. That is a security feature. Anybody looking over your shoulder will not be able to tell how many characters are in your password. The system IS keeping track of the characters you type.
Type in your password and then hit ENTER. You will be allowed into the system.
You gotta love these “security measures” eh?…
Actually, I do. This is one of the more logical ones. It is more sensible than many distro developers “protecting users from themselves” by disallowing explicit root login.
apt for Ubuntu is different from apt for Mint.
That’s correct, there are a number of variations in apt for Ubuntu, and for Mint.
Most of the options in this howto neither work in debian sid (apt 1.4~beta1) or in a fully upgraded Ubuntu 16.10. (apt 1.3.1). And that has nothing to do with apt vs. apt-get. Could the author please point to any sources for commands like ‘apt deb’, ‘apt-check’ or ‘apt version’ or ‘apt content’?
It is actually true that many of the apt options above do not work on Debian or Ubuntu. However, on Linux Mint they look to be working so well, that is the source of the options you see in this How-To, you can test that yourself.
Well, not a big fan of Ubuntu and of Mint here. I just thought, that your headline was a bit off, after trying these commands in Debian. Then someone told me they don’t work in Ubuntu 16.04 either. So I threw 16.10 into a Vbox and …no dice.
If the article is based on Linux Mint, say so in the title. Do not suggest that all the commands work in Debian/Ubuntu which they obviously do not.
not available on 16.04, using latest available apt
apt 1.2.15 (amd64)
Usage: apt [options] command
Most used commands:
list – list packages based on package names
search – search in package descriptions
show – show package details
install – install packages
remove – remove packages
autoremove – Remove automatically all unused packages
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
See apt(8) for more information about the available commands.
# apt content bash
E: Invalid operation content
Am running Linux Mint 18 which is has Ubuntu 16.04 as its core, and apt content bash seems to be working fine. apt on Linux Mint is perhaps different from the one on Debian, Ubuntu and its derivatives. This could be the could be the reason why you are getting the error.
Some of these commands didn’t work on my Ubuntu 16.04 system. I checked to make sure “apt” was installed and it shows as being here, but “version” / “check” / and a few others didn’t work.
Kept getting the error that “version” is an “invalid operation” the same with “check”. So I guess for now? I’ll stick to apt-get and leave this stuff alone until they get it working properly.
No sense in breaking my skull trying to get this to work when it seems to have some glitches in it. (Sigh……..when will they learn to stop trying to “improve” things that are fine as they are?…)
Thanks for offering us your experience and thoughts concerning apt tool. It surely realistic to stick with apt-get that has been tested and works very well on Debian and all its derivatives.
“apt update” doesn’t install any updated packages (even for system/critical updates), it only downloads the updated list of packages.
The system itself may have a mechanism for regularly applying critical updates regularly, but you would do that using the “apt upgrade” command.
Yap, that is so correct. apt update simply downloads an updated package sources list as you have clearly mentioned. We shall update the article to mention this.
The Linux Mint command ‘apt’ is completely different from the one Debian uses — written by different people at different time. The older Mint version has recently been made to mimic the newer Debian version, but it has many more functions unique to it, like ‘version’ and ‘check’. I’d imagine Ubuntu uses the Debian one but I don’t know for certain.
Many thanks for informing us of the difference between apt on Debian and some of its derivatives. Perhaps the developers will look into this issue with great concern to improve user experience.
Try to check the manual entry for apt, some options may not be given in the help info or pages.
i tried to use two of the options in this tutorial and i get the following errors
apt content glances
E: Invalid operation content
apt deb google-chrome-stable_current_amd64.deb
E: Invalid operation deb
It should work just fine, try to run apt get without any options, you should see all the options available that you can use including content and deb.
If it still does not work, try installing it:
sudo apt-get install apt
i tried , but still same issue with marian
which os ubuntu you’re using to excute above option “content,deb,get”
I used Linux Mint and Ubuntu
I am using Ubuntu 16.xx LTS, with APT 1.2.12 , it seems that some options are not there, such as : deb content and get , any idea why ?
Like this one. Crystal-clear.
Thanks for liking it, just keep connected to TecMint.com to get the best.