Search the Community
Showing results for tags 'apt'.
-
In this guide, we will demonstrate a number of ways of using the APT command on Linux. Prerequisites To perform the steps demonstrated in this guide, you will need the following components: A properly configured Linux distro that uses APT as the package manager, for example, Debian, Ubuntu, Linux Mint, Devuan, etc. Basic understanding of the CLI and package management. The APT Command Any Linux distro comprises a number of packages. To manage these numerous packages in an efficient manner, almost all distros use one or more package managers. APT is one such package manager. It’s a CLI tool that can install, uninstall, and manage DEB packages on distros like Debian, Ubuntu, and Debian/Ubuntu-based ones. If an APT command is to make system-level changes, it must run with root privilege (with the help of the sudo command). Using the APT Command Example 1: Updating the List of Available Packages Before APT can work with packages, it needs a working database of all the available packages. To generate the most up-to-date database, run the following command: sudo apt update Here, APT will fetch the latest package database from the package repo(s). If any package update is available, APT will also print a notification. Example 2: List Available Package Upgrades If APT finds package upgrades, the following command will list all of them: apt list --upgradable Example 3: Upgrading Packages If one or more package updates were found, then you can upgrade all of them at once using the following command: sudo apt upgrade Alternatively, the following command will upgrade the whole system by removing, installing, and upgrading packages as needed: sudo apt full-upgrade Example 4: Upgrading Specific Packages If you don’t want to install all the package upgrades but specific ones, use the following command structure: sudo apt --only-upgrade install [package_name] Example 5: Downgrading Packages Sometimes, a package upgrade may break things. In such a situation, you may want to downgrade the problematic package(s) to an earlier version. To downgrade a package, run the following command: apt install [package_name]=[older_package_version] Example 6: Searching for a Package To check if a package is available from the package repo, use the following command: apt search [package_name] Example 7: Installing a Package If a package exists on the package repo(s) specified in the sources.list, then you can directly install it using the following command: sudo apt install [package_name] Example 8: Installing a Specific Package Version The procedure is the same as example #5. If you want to install a specific version of a package, specify it in the following manner: sudo apt install [package_name]=[package_version] If the package version is not specified, then APT will automatically install the latest package. Example 9: Listing Available Package Versions The default package repo(s), in most cases, will host multiple versions of a package. The following command will reveal all the available package versions: apt-cache policy [package_name] Example 10: Holding a Package Whenever running the apt upgrade command, it will check for upgrades for all the installed packages. In certain situations, however, you may want to skip upgrading certain packages for various reasons (stability, compatibility, etc.). In such a situation, you can mark the target package(s) as hold. Basically, whenever performing automatic package upgrades, APT will skip these packages. To mark a package as hold, run the following command: sudo apt-mark hold [package_name] To get a list of all the hold packages, run the following command: apt-mark showhold To remove the hold mark from a package, use the following command: sudo apt-mark unhold [package_name] Example 11: Installing a DEB Package Debian and Debian-based systems use DEB as the software packaging. All the packages from the package repo(s) also come as DEB files. To install a DEB package, use the following APT command: sudo apt install [path_to_deb] APT should take care of all the necessary dependencies as well. Example 12: Uninstalling a Package To uninstall a package, use the following command: sudo apt remove [package_name] Generally, APT won’t remove the package dependencies. To remove them afterward, run the following command: sudo apt autoremove We can also instruct APT to perform both of these actions in a single command: sudo apt autoremove --purge [package_name] Note that purging a package will also remove all the package-related configuration files, so exercise caution. Example 13: Listing Installed Packages APT keeps track of all the packages installed from the package repo(s) and DEB packages. The following command will list all the installed packages that APT is keeping track of: apt list --installed We can filter this output using grep to check if a package with a particular name/pattern is installed: apt list --installed | grep [pattern] Learn more about grep. Example 14: Package Details Before installing a package from the repo, we can check detailed info about it: apt show [package_name] Example 15: Downloading a Package from Repo To download a package from the package repo(s) without installing it, use the following command: apt download [package_name] It will download the package as a DEB file in the current directory. You can later install it using APT following the steps demonstrated in example #11. Bonus: Editing sources.list The sources.list file contains the URL for all the APT repos. We can open it using APT for editing: sudo apt edit-sources Alternatively, we can manually edit it using any text editor: sudo vim /etc/apt/sources.list In the case of Ubuntu, to auto select the nearest mirror, update the repo URLs with the following one: mirror://mirrors.ubuntu.com/mirrors.txt After updating sources.list, you have to update the APT cache: sudo apt update Bonus: APT Documentation The following command will print a quick help page: apt --help To learn more about all the available options with in-depth explanations, check out the man page: man apt Final Thoughts In this guide, we demonstrated numerous ways of using the APT command. We learned about installing, uninstalling, upgrading, downgrading, and downloading packages on Debian and Debian-based systems. While APT handles DEB packages, there are other Linux packaging formats, for example, flatpak, snap, etc. These packages are designed to be practically universal Linux packages that can be installed on any Linux system. Happy computing! View the full article
-
The post apt-fast: Speeds Up Your APT Package Downloads in Ubuntu first appeared on Tecmint: Linux Howtos, Tutorials & Guides .In this editorial, we take a look at a great and powerful utility called apt-fast that you can use to speed up downloading packages by The post apt-fast: Speeds Up Your APT Package Downloads in Ubuntu first appeared on Tecmint: Linux Howtos, Tutorials & Guides.View the full article
-
Managing software packages in Linux is essential to maintain regular processes and services. The Advance Package Tool, or APT, is a package manager developed especially for Ubuntu, Debian, and a few similar Linux distributions. Apt offers various options to install, update, and upgrade software packages. APT is a reliable and easy-to-use utility that you can primarily access using a command-line interface. Moreover, it also ensures that all the required components for a given package are installed properly when installing and upgrading packages. However, many beginner users are unaware of APT’s capabilities. So, this guide will comprehensively describe APT in Linux with examples of how to use it. How to Use APT to Install Packages in Linux Using APT is simple, so let’s start with installing or upgrading the system through the following command: sudo apt update Now, please run the following apt command to install your desired utility: sudo apt install util_name In this command, you should replace util_name with the package name you want to install. For instance, to install the rsync utility, we will use: sudo apt install rsync Similarly, you can use the remove option to completely uninstall the package. For example, to remove the rsync utility, please run the below command: sudo apt remove rsync In case you want to remove all the unused packages from the system then please use the autoremove option: sudo apt autoremove You can also use the full-upgrade option to upgrade the system by removing, upgrading, and installing packages: sudo apt full-upgrade If you intend to upgrade a specific package, please use the following command: sudo apt install --only-upgrade util_name Here, replace util_name with the particular utility name you want to upgrade. Let’s upgrade the curl utility for an example: sudo apt install --only-upgrade curl Moreover, you can run the following command to see the list of all the available options in the apt utility: apt --help apt-get Vs. apt Beginners and even a few seasoned Linux users need clarification on apt and apt-get. Both the apt and apt-get commands are a part of the APT utility, where apt-get is older and apt is a newer and more advanced tool. On the other hand, apt includes additional features, like verbose output, which are not available in apt-get. However, apt-get still holds the top position as the widely used package manager in Debian-based distributions. A Quick Wrap-up APT is a popular Linux package management tool with multiple commands for installing, updating, and upgrading software packages. For users unaware of its correct usage methods, this guide comprehensively explains what apt is and how you can use it to install various packages in Linux. Furthermore, we describe a few apt commands to upgrade, uninstall, list, remove, and get detailed information about those software packages. View the full article
-
Forum Statistics
67.4k
Total Topics65.3k
Total Posts