16 Useful apt Command Examples for Ubuntu/Debian Linux

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 containing binary files, configuration files, and information about the application’s dependencies.

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, 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 the apt command examples, which are most commonly used in Debian-based Linux distributions, such as Ubuntu, to manage software packages.

The apt is a command-line-based package management tool that offers more functionalities than the older apt-get command and apt-cache command into a single command.

The apt command is used to manage package installation, upgrades, and removal in Debian-based Linux distributions, such as Ubuntu, Linux Mint, and others.

1. Install Package in Ubuntu

To install a package named “glances“, you would use the ‘apt install‘ command which will install a package along with the needed dependencies.

$ sudo apt install glances
Install Package in Ubuntu
Install a Package in Ubuntu

2. View Installed Files From a Package

The following ‘apt content‘ command will display a list of files and directories that are installed on your system as part of the specified package called glances.

$ sudo apt content glances
List of Installed Files From a Package
List of Installed Files From a Package

3. Check the Dependencies of a Package in Ubuntu

To view the dependencies of a package you can use the apt depends command, which displays a list of the dependencies of the specified package called glances.

$ sudo apt depends glances
Check Dependencies of Package
Check Dependencies of Package

4. Search for a Package in Ubuntu

The apt search command is used to search for packages in the repositories available based on keywords in their names or descriptions.

For example, to search for packages related to the apache2 web server, you would use the following command:

$ sudo apt search apache2
Search For a Package
Search For a Package

Alternatively, you can also use the apt-cache command to search for a package in the system package cache based on a given search term such as name or description.

5. Show Information About a Package in Ubuntu

The apt show command is used to display detailed information about a specific package, which includes its version, size, description, dependencies, and other relevant details.

$ sudo apt show firefox
Show Package Information
Show Package Information

6. Check 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
Check Package for Broke Dependencies
Check Package for Broke Dependencies

7. List Missing Dependencies of Package

To view the recommended missing packages for the apache2 package, you can use the apt recommends command as shown.

$ sudo apt recommends apache2
View Missing Dependencies of Package
View Missing Dependencies of Package

8. Check the Version of Installed Package on Ubuntu

The apt version command allows you to check the installed version and availability of a package in the repositories.

$ sudo apt version firefox
Check Installed Package Version
Check Installed Package Version

9. Update All Packages On Ubuntu

The apt update command 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
Update System Packages in Ubuntu
Update System Packages in Ubuntu

10. Upgrade Ubuntu System

The apt upgrade command is used to upgrade installed packages on a system to their latest available versions. It retrieves the latest package versions from the repositories and installs them, replacing any older versions that are currently installed.

$ sudo apt upgrade
Upgrade Ubuntu System
Upgrade Ubuntu System

11. Remove Unused Packages in Ubuntu

The apt autoremove command is used to remove packages that were automatically installed as dependencies but are no longer needed by any other package on your system.

These packages may have been installed in the past to satisfy the dependencies of other packages, but if those dependencies are no longer present, the packages become unnecessary.

$ sudo apt autoremove
Remove Unwanted Packages in Ubuntu
Remove Unwanted Packages in Ubuntu

12. Clear Apt Cache in Ubuntu

The apt autoclean or apt clean command is used to clean up the local repository cache by removing old package files that are no longer needed.

$ sudo apt autoclean 
$ sudo apt clean
Clean Package Repository
Clean Package Repository

13. Completely Remove a Package in Ubuntu

When you run apt with remove, it only removes the package files but configuration files remain on the system. Therefore, you will have to use purge to remove a package and its configuration files.

$ sudo apt purge glances
Remove Package with Configuration Files
Remove Package with Configuration Files

14. Install Deb Package in Ubuntu

To install a .deb package file, run the command below with the filename as an argument as follows:

$ sudo apt deb atom-amd64.deb
Install Deb Package in Ubuntu
Install Deb Package in Ubuntu

15. Uninstall Packages in Ubuntu

The apt remove command is used to uninstall or remove a specific package from your system.

$ sudo apt remove wget
Remove a Package in Ubuntu
Remove a Package in Ubuntu

16. APT Command Help

The apt help command provides a built-in help system that can provide information on how to use various apt commands and their options.

$ apt help
APT Command Help
APT Command Help

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.

Hey TecMint readers,

Exciting news! Every month, our top blog commenters will have the chance to win fantastic rewards, like free Linux eBooks such as RHCE, RHCSA, LFCS, Learn Linux, and Awk, each worth $20!

Learn more about the contest and stand a chance to win by sharing your thoughts below!

Aaron Kili
Aaron Kili is a Linux and F.O.S.S enthusiast, an upcoming Linux SysAdmin, web developer, and currently a content creator for TecMint who loves working with computers and strongly believes in sharing knowledge.

Each tutorial at TecMint is created by a team of experienced Linux system administrators so that it meets our high-quality standards.

Join the TecMint Weekly Newsletter (More Than 156,129 Linux Enthusiasts Have Subscribed)
Was this article helpful? Please add a comment or buy me a coffee to show your appreciation.


Leave a Reply
  1. Hi,

    I have a problem with my Debian Installation:

    ...@localhost´s password: 

    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.

  2. 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’?

    • @Ferdinand

      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.

  3. not available on 16.04, using latest available apt

    # 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

    • @For

      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.

  4. 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?…)

    • @Eddie G

      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.

  5. “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.

    • @airdrik

      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.

  6. 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.

  7. @ALJI Mohamed

    Try to check the manual entry for apt, some options may not be given in the help info or pages.

  8. 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


Got Something to Say? Join the Discussion...

Thank you for taking the time to share your thoughts with us. We appreciate your decision to leave a comment and value your contribution to the discussion. It's important to note that we moderate all comments in accordance with our comment policy to ensure a respectful and constructive conversation.

Rest assured that your email address will remain private and will not be published or shared with anyone. We prioritize the privacy and security of our users.