Introduction
The apt command is a powerful package management tool used to install, update, remove, and manage packages on Ubuntu and Debian Linux systems. It is the most popular package manager for Debian-based systems, and is used by millions of users around the world. In this article, we will discuss 16 useful apt command examples for Ubuntu/Debian Linux. We will cover topics such as installing packages, updating packages, removing packages, and more. We hope this article will help you get the most out of your Ubuntu/Debian Linux system.
16 Useful apt Command Examples for Ubuntu/Debian Linux
1. Update the package list:
sudo apt update
2. Install a package:
sudo apt install 3. Remove a package: sudo apt remove 4. Search for a package: sudo apt search 5. Upgrade all packages: sudo apt upgrade 6. Upgrade a specific package: sudo apt upgrade 7. List installed packages: sudo apt list –installed 8. List all available packages: sudo apt list 9. Show package information: sudo apt show 10. Download a package without installing it: sudo apt download 11. Clean up the local repository of downloaded packages: sudo apt clean 12. Remove packages that are no longer needed: sudo apt autoremove 13. Reinstall a package: sudo apt reinstall 14. List packages that are upgradable: sudo apt list –upgradable 15. List packages that are upgradable with their versions: sudo apt list –upgradable –all-versions 16. List packages that are upgradable with their versions and dependencies: sudo apt list –upgradable –all-versions –with-dependencies 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: 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 is used to manage package installation, upgrades, and removal in Debian-based Linux distributions, such as Ubuntu, Linux Mint, and others. To install a package named “glances“, you would use the ‘apt install‘ command which will install a package along with the needed dependencies. 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. 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. 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: 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. 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. To view the recommended missing packages for the apache2 package, you can use the apt recommends command as shown. The apt version command allows you to check the installed version and availability of a package in the repositories. 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. 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. 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. 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. 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. To install a .deb package file, run the command below with the filename as an argument as follows: The apt remove command is used to uninstall or remove a specific package from your system. The apt help command provides a built-in help system that can provide information on how to use various apt commands and their options. 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. The apt command is a powerful command-line tool, which works with Ubuntu/Debian to manage the software and packages. It provides a simple and easy-to-use command line interface to manage the software and packages. In this article, we will explain some useful apt command examples for Ubuntu/Debian Linux. The apt command can be used to update the system. It will download the package information from all configured sources and update the system’s package list. To update the system, run the following command: The apt command can also be used to upgrade the system. It will download and install the available updates for the system. To upgrade the system, run the following command: The apt command can be used to install a package. It will download and install the package and its dependencies. To install a package, run the following command: The apt command can also be used to remove a package. It will remove the package and its configuration files. To remove a package, run the following command: The apt command can be used to search for a package. It will search for the package in the configured sources and display the results. To search for a package, run the following command: The apt command can also be used to show the information about a package. It will display the package’s description, version, size, and other information. To show the package information, run the following command: The apt command can be used to clean the cache. It will remove the cached packages and other files from the system. To clean the cache, run the following command: The apt command can also be used to autoremove unused packages. It will remove the packages that were installed as dependencies but are no longer required. To autoremove unused packages, run the following command: The apt command can be used to download a package. It will download the package and its dependencies from the configured sources. To download a package, run the following command: The apt command can also be used to list the installed packages. It will list all the packages that are installed on the system. To list the installed packages, run the following command: The apt command can be used to list the available packages. It will list all the packages that are available in the configured sources. To list the available packages, run the following command: The apt command can also be used to list the upgradeable packages. It will list all the packages that have available updates. To list the upgradeable packages, run the following command: The apt command can be used to list the dependencies of a package. It will list all the packages that are required by the specified package. To list the dependencies of a package, run the following command: The apt command can also be used to list the packages by name. It will list all the packages that match the specified name. To list the packages by name, run the following command: The apt command can be used to list the packages by status. It will list all the packages that have the specified status. To list the packages by status, run the following command: The apt command can also be used to list the packages by version. It will list all the packages that match the specified version. To list the packages by version, run the following command:
1. Install Package in Ubuntu
$ sudo apt install glances
2. View Installed Files From a Package
$ sudo apt content glances
3. Check the Dependencies of a Package in Ubuntu
$ sudo apt depends glances
4. Search for a Package in Ubuntu
$ sudo apt search apache2
5. Show Information About a Package in Ubuntu
$ sudo apt show firefox
6. Check Package for Any Broken Dependencies
$ sudo apt check firefox
7. List Missing Dependencies of Package
$ sudo apt recommends apache2
8. Check the Version of Installed Package on Ubuntu
$ sudo apt version firefox
9. Update All Packages On Ubuntu
$ sudo apt update
10. Upgrade Ubuntu System
$ sudo apt upgrade
11. Remove Unused Packages in Ubuntu
$ sudo apt autoremove
12. Clear Apt Cache in Ubuntu
$ sudo apt autoclean
or
$ sudo apt clean
13. Completely Remove a Package in Ubuntu
$ sudo apt purge glances
14. Install Deb Package in Ubuntu
$ sudo apt deb atom-amd64.deb
15. Uninstall Packages in Ubuntu
$ sudo apt remove wget
16. APT Command Help
$ apt help
Summary
16 Useful apt Command Examples for Ubuntu/Debian Linux
1. Update the System
$ sudo apt update
2. Upgrade the System
$ sudo apt upgrade
3. Install a Package
$ sudo apt install
4. Remove a Package
$ sudo apt remove
5. Search for a Package
$ sudo apt search
6. Show Package Information
$ sudo apt show
7. Clean the Cache
$ sudo apt clean
8. Autoremove Unused Packages
$ sudo apt autoremove
9. Download a Package
$ sudo apt download
10. List Installed Packages
$ sudo apt list --installed
11. List Available Packages
$ sudo apt list
12. List Upgradeable Packages
$ sudo apt list --upgradeable
13. List Dependencies of a Package
$ sudo apt depends
14. List Packages by Name
$ sudo apt list --name-only
15. List Packages by Status
$ sudo apt list --status-only
16. List Packages by Version
$ sudo apt list --version-only