{"id":6223,"date":"2018-12-28T07:03:10","date_gmt":"2018-12-28T07:03:10","guid":{"rendered":"https:\/\/www.appservgrid.com\/paw92\/?p=6223"},"modified":"2018-12-28T23:09:09","modified_gmt":"2018-12-28T23:09:09","slug":"apt-package-management-tool-linux-hint","status":"publish","type":"post","link":"https:\/\/www.appservgrid.com\/paw92\/index.php\/2018\/12\/28\/apt-package-management-tool-linux-hint\/","title":{"rendered":"Apt Package Management Tool \u2013 Linux Hint"},"content":{"rendered":"<p>Your Linux machine is only as good as you make it. To make it into a powerful machine, you need to install the right packages, use the right configurations among a host of other things. Talking about packages; in this article I would be taking a primer on the APT package management tool. Similar to YUM for RHEL(RedHat Enterprise Linux) based Linux distributions\u2014which was discussed here\u2014APT(Advanced Packaging Tool) is for managing packages on Debian and Ubuntu based Linux distributions.This article isn\u2019t planned to discuss all the powers of the APT package management tool, instead it is intended to give you a quick look into this tool and how you can use it. It would serve well for reference purposes and understanding how the tool works. Without much ado, let\u2019s get started.<\/p>\n<h3>Location<\/h3>\n<p>Just like many Linux tools, apt is stored in the \/etc directory\u2014contains the configuration files for all the programs that run on Linux systems\u2014and can be viewed by navigating to the directory.<\/p>\n<p>Apt also has a configuration file which can be found in the \/etc\/apt directory with the file name apt.conf.<\/p>\n<p>You would be doing a lot of package installations with apt, therefore it would go a long way to know that package sources are stored in a sources.list file. Basically, apt checks this file for packages and attempt to install from the list of packages\u2014let\u2019s call it a repository index.<\/p>\n<p>The sources.list file is stored in the \/etc\/apt directory and there is a similar file, named sources.list.d. It isn\u2019t actually a file, but a directory which keeps other sources.list files. The sources.list.d directory is used by Linux for keeping some sources.list files in a separate place\u2014outside the standard \/etc\/apt directory.<\/p>\n<h3>The confusion: APT vs APT-GET<\/h3>\n<p>Yes, a lot of people actually mistake apt to be the same as apt-get. Here\u2019s a shocker: they are not the same.<\/p>\n<p>In truth, apt and apt-get work similarly however the tools are different. Let\u2019s consider apt to be an upgrade on apt-get.<\/p>\n<p>Apt-get has been in existence before apt. However apt-get doesn\u2019t exist in isolation as it works together with other apt packages such as apt-cache and apt-config. These tools when combined are used to manage linux packages and have different commands as well. Also these tools are not the easiest to use as they work at a low level, which an average Linux user couldn\u2019t care less about.<\/p>\n<p>For this reason, apt was introduced. The version 1.0.1 of APT has the following on the man page, <em>\u201cThe apt command is meant to be pleasant for end users and does not need to be backward compatible like apt-get.\u201d<\/em><\/p>\n<p>Apt works in isolation and doesn\u2019t need to be combined with other tools for proper Linux administration, plus it is easy to use.<\/p>\n<p>For an average Linux user, the commands are all that matter. Through the commands, tasks are executed and actual work can be done. Let\u2019s take a look at the major apt commands.<\/p>\n<h3>Get Help<\/h3>\n<p>The most important of all the commands to be discussed in this article is the command used to get help. It makes the tool easy to use and ensures you do not have to memorize the commands.<\/p>\n<p>The help provides enough information to carry out simple tasks and can be accessed with the command below:<\/p>\n<p>You would get a list of various command combinations from the result, you should get something similar to the image below:<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/linuxhint.com\/wp-content\/uploads\/2018\/12\/1-26.png\" alt=\"\" width=\"699\" height=\"484\" \/><\/p>\n<p>If you desire, you could check out the apt man pages for more information. Here\u2019s the command to access the man pages:<\/p>\n<h3>Search for package<\/h3>\n<p>For a lot of operations, you would need to know the exact name of a package. This and many more uses are reasons to make use of the search command.<\/p>\n<p>This command checks all the packages in the repository index, searches the keyword in the package descriptions and provides a list of all packages with the keyword.<\/p>\n<h3>Check package dependencies<\/h3>\n<p>Linux packages have dependencies, these dependencies ensure they function properly as the packages break when the dependencies break.<\/p>\n<p>To view a package\u2019s dependencies, you use the depends command.<\/p>\n<p>apt depends &lt;package name&gt;<\/p>\n<h3>Display package information<\/h3>\n<p>Displaying a package\u2019s dependencies is one information you would find useful. However, there are other package details you can get. For me, it would be less productive to memorize all the commands to access other details such as the package\u2019s version, download size etc.<\/p>\n<p>You can get all of a package\u2019s information in one attempt using the apt command as seen below:<\/p>\n<h3>Install package<\/h3>\n<p>One of Linux\u2019s strongest points is the availability of lots of powerful packages. You can install packages in two ways: either through the package name or through a deb file\u2014deb files are debian software package files.<\/p>\n<p>To install packages using the package name, the command below is used:<\/p>\n<p>apt install &lt;package name&gt;<\/p>\n<p>As stated earlier, you need to know the package name before using it. For example, to install Nginx the command would be apt install nginx.<\/p>\n<p>The other means of installing packages is the through the deb file if available. When installing a package through its deb file, apt fetches the package dependencies itself and downloads it so you do not have to worry about them.<\/p>\n<p>You can install deb files using the absolute path to the files with the command below:<\/p>\n<p>apt install &lt;\/path\/to\/file\/file_name.deb&gt;<\/p>\n<h3>Download package<\/h3>\n<p>If for some reason, you need to download a package without having it installed, you can do so using the download command.<\/p>\n<p>This would download the package\u2019s deb file into the directory where the command was run. You can download packages using the command below:<\/p>\n<p>apt download &lt;package name&gt;<\/p>\n<p>If you are then interested in installing the .deb file, you can then install using the install command.<\/p>\n<h3>Update repository index<\/h3>\n<p>Remember we talked about sources.list earlier? Well, when a new version of a package is released, your linux machine is not able to install it yet because it would not indicate. To have it indicate, it needs to reflect in the sources.list file and this can be done using the update command.<\/p>\n<p>This command refreshes the repository index and keeps it up-to-date with the latest changes to the listed packages.<\/p>\n<h3>Remove packages<\/h3>\n<p>Packages break. Packages become obsolete. Packages need to be removed.<\/p>\n<p>Apt makes it easy to remove packages. Here are different conditions to removing packages: removing the binary files and keeping the config files, removing the binary files and the config files.<\/p>\n<p>To remove the binary files alone, the remove command is used.<\/p>\n<p>apt remove &lt;package name&gt;<\/p>\n<p>More than one package can be removed, so you can have apt remove nginx top to remove the Nginx and top packages at the same time.<\/p>\n<p>To remove the configuration files, the purge command is used.<\/p>\n<p>If you wish to do both at once, the commands can be combined as seen below:<\/p>\n<p>apt remove &#8211;purge &lt;package name&gt;<\/p>\n<p>Before proceeding, it should be known that when packages are removed, their dependencies remain i.e. they are not removed too. To remove the dependencies while uninstalling, the autoremove command is used as seen below:<\/p>\n<p>apt autoremove &lt;package name&gt;<\/p>\n<h3>List packages<\/h3>\n<p>Yes, you can have the packages on your Linux machine listed. You can have a list of all packages in the repository index, installed packages and upgradeable packages.<\/p>\n<p>Regardless what you intend doing, the list command would be used.<\/p>\n<p>The command above is used to list all the packages available in the repository index.<\/p>\n<p>The command above is used to list the packages installed on your Linux machine.<\/p>\n<p>The command above is used to list the packages installed on your machine that have upgrades available.<\/p>\n<h3>Updating packages<\/h3>\n<p>When it comes to packages, it\u2019s not all about installing and removing packages; they need to be updated too.<\/p>\n<p>You can decide to upgrade a single package or all packages at once. To update a single package, the install command is going to be used. Surprising right? Yes, however we are going to be adding the \u2013only-upgrade parameter.<\/p>\n<p>apt install &#8211;only-upgrade &lt;package name&gt;<\/p>\n<p>This works when you intend upgrading just one package. However, if you want to upgrade all the packages you would need to use the upgrade command.<\/p>\n<p>The following command would be used to make such an upgrade:<\/p>\n<p>It should be noted that the upgrade command doesn\u2019t remove dependencies and even if the upgraded packages do not need them anymore i.e. they are obsolete.<\/p>\n<h3>System upgrade<\/h3>\n<p>Unlike the regular upgrade, the full-upgrade command to be discussed here performs a complete system upgrade.<\/p>\n<p>With the full-upgrade command, obsolete packages and dependencies are removed and all packages (including system packages) are upgraded to their latest versions.<\/p>\n<p>The command for doing this, is full-upgrade as seen below:<\/p>\n<h4>Conclusion<\/h4>\n<p>Apt is a powerful tool that makes the use of Debian and Ubuntu based Linux distributions a wonderful experience. Most of the apt commands listed here require root permissions, so you may need to add sudo to the start of the commands.<\/p>\n<p>These commands are just a tip of the iceberg of the immense powers that the apt tool possesses, and they are powerful enough to get you comfortable with managing packages on your Linux machine.<\/p>\n<p><a href=\"https:\/\/linuxhint.com\/primer_apt_package_management_tool\/\" target=\"_blank\" rel=\"noopener\">Source<\/a><\/p>\n","protected":false},"excerpt":{"rendered":"<p>Your Linux machine is only as good as you make it. To make it into a powerful machine, you need to install the right packages, use the right configurations among a host of other things. Talking about packages; in this article I would be taking a primer on the APT package management tool. Similar to &hellip; <\/p>\n<p class=\"link-more\"><a href=\"https:\/\/www.appservgrid.com\/paw92\/index.php\/2018\/12\/28\/apt-package-management-tool-linux-hint\/\" class=\"more-link\">Continue reading<span class=\"screen-reader-text\"> &#8220;Apt Package Management Tool \u2013 Linux Hint&#8221;<\/span><\/a><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[1],"tags":[],"class_list":["post-6223","post","type-post","status-publish","format-standard","hentry","category-linux"],"_links":{"self":[{"href":"https:\/\/www.appservgrid.com\/paw92\/index.php\/wp-json\/wp\/v2\/posts\/6223","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.appservgrid.com\/paw92\/index.php\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.appservgrid.com\/paw92\/index.php\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.appservgrid.com\/paw92\/index.php\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.appservgrid.com\/paw92\/index.php\/wp-json\/wp\/v2\/comments?post=6223"}],"version-history":[{"count":1,"href":"https:\/\/www.appservgrid.com\/paw92\/index.php\/wp-json\/wp\/v2\/posts\/6223\/revisions"}],"predecessor-version":[{"id":6844,"href":"https:\/\/www.appservgrid.com\/paw92\/index.php\/wp-json\/wp\/v2\/posts\/6223\/revisions\/6844"}],"wp:attachment":[{"href":"https:\/\/www.appservgrid.com\/paw92\/index.php\/wp-json\/wp\/v2\/media?parent=6223"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.appservgrid.com\/paw92\/index.php\/wp-json\/wp\/v2\/categories?post=6223"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.appservgrid.com\/paw92\/index.php\/wp-json\/wp\/v2\/tags?post=6223"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}