{"id":1616,"date":"2021-02-01T03:57:23","date_gmt":"2021-02-01T02:57:23","guid":{"rendered":"https:\/\/codedoneright.eu\/?page_id=1616"},"modified":"2021-02-01T03:57:23","modified_gmt":"2021-02-01T02:57:23","slug":"apt-managing-software","status":"publish","type":"page","link":"https:\/\/codedoneright.eu\/?page_id=1616","title":{"rendered":"APT \u2013 managing software"},"content":{"rendered":"\n<div style=\"height:56px\" aria-hidden=\"true\" class=\"wp-block-spacer\"><\/div>\n\n\n\n<h4 class=\"wp-block-heading\">What is APT?<\/h4>\n\n\n\n<p>APT stands for Advanced Packaging Tool \u2013 it is a collection of tools that help with package management. Software written for Linux and available to the end-user via repository is called a package. It does not matter if you are downloading a shared library that is used by many programs or a stand-alone program. It all comes in form of a package. Apt is what helps you download and install that software.<\/p>\n\n\n\n<div style=\"height:56px\" aria-hidden=\"true\" class=\"wp-block-spacer\"><\/div>\n\n\n\n<h4 class=\"wp-block-heading\">How a package is made available to the end-user?<\/h4>\n\n\n\n<p>The process of adding software to repository looks like this<\/p>\n\n\n\n<ul><li>Software is written and released on an open source platform<\/li><li>Software is packaged for a particular distribution<\/li><li>Package with software is added to that distribution&#8217;s repository<\/li><li>Package is ready for installation via repository<\/li><\/ul>\n\n\n\n<p>It is a bit more complex than the above process, but more or less this is how the cycle looks like. Once a particular package gets added to repository, you can simply download the software.<\/p>\n\n\n\n<p>But where all those packages actually are, where is the physical data? There are many institutions that are happy to lend their servers and host those resources. Just take a look at the list of <a href=\"http:\/\/www.debian.org\/mirror\/list\" target=\"_blank\" rel=\"noreferrer noopener\">Debian mirrors<\/a>. All those servers host software packages, and if one of them is down, <em>apt<\/em> simply uses a different server to grab data. <\/p>\n\n\n\n<div style=\"height:56px\" aria-hidden=\"true\" class=\"wp-block-spacer\"><\/div>\n\n\n\n<h4 class=\"wp-block-heading\">A treasure map to software \u2013 sources list<\/h4>\n\n\n\n<p>In order to know where those servers are, <em>apt<\/em> uses a file called <em>sources.list<\/em>. Think of it as a treasure map, but instead of treasure you get software.<\/p>\n\n\n\n<p>The file can be found in the following location<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>\/etc\/apt\/sources.list<\/code><\/pre>\n\n\n\n<p>Unless you know what you are doing, you should not modify this file. <\/p>\n\n\n\n<p>You can read more about sources list on Debian wiki \u2013 <a href=\"http:\/\/wiki.debian.org\/SourcesList\" target=\"_blank\" rel=\"noreferrer noopener\">here<\/a>. However, for now it is enough that you know from where you get the software.<\/p>\n\n\n\n<div style=\"height:56px\" aria-hidden=\"true\" class=\"wp-block-spacer\"><\/div>\n\n\n\n<h4 class=\"wp-block-heading\">Information vs action<\/h4>\n\n\n\n<p><em>apt<\/em> can be used with or without administrative privileges. If you want to use <em>apt<\/em> in order to obtain <em>information<\/em>, you do not need root access or sudo. However, in order to <em>modify<\/em> anything, you need to be logged as root or prefix the command with sudo.<\/p>\n\n\n\n<p>Commands below will not be prefixed with sudo. Any command that modifies files will need to be executed as root or with sudo.<\/p>\n\n\n\n<div style=\"height:56px\" aria-hidden=\"true\" class=\"wp-block-spacer\"><\/div>\n\n\n\n<h4 class=\"wp-block-heading\">Using apt to manage packages<\/h4>\n\n\n\n<p>The syntax of <em>apt<\/em> is quite simple, take a look<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>apt &#91;option1] &#91;option2]<\/code><\/pre>\n\n\n\n<p>Using apt on its own prints a brief description and a collection of most commonly used options<\/p>\n\n\n\n<ul><li>update \u2013 update list of available packages<\/li><li>upgrade \u2013 upgrade the system by installing \/ upgrading packages<\/li><li>autoremove \u2013 remove automatically all unused packages<\/li><li>install [option] \u2013 install packages<\/li><li>remove [option] \u2013 remove packages<\/li><li>purge [option] \u2013 completely remove package<\/li><li>reinstall [option] \u2013 reinstall packages<\/li><\/ul>\n\n\n\n<div style=\"height:56px\" aria-hidden=\"true\" class=\"wp-block-spacer\"><\/div>\n\n\n\n<h4 class=\"wp-block-heading\">Updating your system with apt<\/h4>\n\n\n\n<p>One of the most common uses of <em>apt<\/em> is <\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>apt update<\/code><\/pre>\n\n\n\n<p>This command simply updates your local software database. If there are newer versions of currently installed packages then <em>apt<\/em> will print out a message informing you about it. You can check what can be upgraded with<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>apt list --upgradable<\/code><\/pre>\n\n\n\n<p><em>apt<\/em> will then print out a nice list of what can be upgraded. If you want to upgrade those packages, it is as simple as issuing<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>apt upgrade<\/code><\/pre>\n\n\n\n<p>The process of updating the repository index and upgrading all packages should be performed as the first step after setting up any system.<\/p>\n\n\n\n<div style=\"height:56px\" aria-hidden=\"true\" class=\"wp-block-spacer\"><\/div>\n\n\n\n<h4 class=\"wp-block-heading\">Installing a package<\/h4>\n\n\n\n<p>In order to install a package you can simply issue the following command<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>apt install $some_software<\/code><\/pre>\n\n\n\n<p>Provided you have internet access, <em>$some_software<\/em> will be installed. <\/p>\n\n\n\n<p>Usually there are many other packages installed as well, those are called <em>dependencies<\/em>. In order to minimize the amount of space that a particular program takes, it is common to use shared libraries. <\/p>\n\n\n\n<p>If for example you are using two video players it would be unwise to install two sets of codecs, one set is enough and both players can make use of them. This is a rudimentary example, but this is the philosophy of dependencies. <\/p>\n\n\n\n<div style=\"height:56px\" aria-hidden=\"true\" class=\"wp-block-spacer\"><\/div>\n\n\n\n<h4 class=\"wp-block-heading\">Uninstalling a package<\/h4>\n\n\n\n<p>If you want to remove a package from your machine it is as easy as<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>apt remove $some_software<\/code><\/pre>\n\n\n\n<p>This, however, removes only the specified package. Furthermore, configuration files created by that package are left as they are, and no dependencies are being removed. This is done in case you decide to reinstall the package later or not to break other packages using dependencies.<\/p>\n\n\n\n<div style=\"height:56px\" aria-hidden=\"true\" class=\"wp-block-spacer\"><\/div>\n\n\n\n<h4 class=\"wp-block-heading\">Purging a package<\/h4>\n\n\n\n<p>Purge works identical to remove, however, it removes configuration files as well<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>apt purge $some_package<\/code><\/pre>\n\n\n\n<p>Purge is useful if you are confident you will no longer use certain package, or if you want to remove everything and get a fresh configuration files.<\/p>\n\n\n\n<div style=\"height:56px\" aria-hidden=\"true\" class=\"wp-block-spacer\"><\/div>\n\n\n\n<h4 class=\"wp-block-heading\">Removing orphaned dependencies<\/h4>\n\n\n\n<p>Removing a package often leaves dependencies that we installed alongside the main package. If that package was the only one using those dependencies they will be orphaned and are no longer needed. <\/p>\n\n\n\n<p>By default <em>apt<\/em> does not remove dependencies alongside the main package since they might be used by other packages. This is done in order to prevent a package from being unusable.<\/p>\n\n\n\n<p>However, if a dependency is no longer needed by any package it is then safe to remove it.<\/p>\n\n\n\n<p>This is done by issuing the following command<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>apt autoremove<\/code><\/pre>\n\n\n\n<p><strong>Note!<\/strong> After performing an update, apt will alert the user that there are dependencies that are no longer needed and can be safely removed.<\/p>\n\n\n\n<div style=\"height:56px\" aria-hidden=\"true\" class=\"wp-block-spacer\"><\/div>\n\n\n\n<h4 class=\"wp-block-heading\">Reinstalling a package<\/h4>\n\n\n\n<p>If for some reason a package is not behaving as intended, you can simply reinstall that package. It is uncommon, but happens. <\/p>\n\n\n\n<p>To reinstall a package issue the following command<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>apt reinstall $some_package<\/code><\/pre>\n\n\n\n<div style=\"height:56px\" aria-hidden=\"true\" class=\"wp-block-spacer\"><\/div>\n\n\n\n<h4 class=\"wp-block-heading\">apt vs apt-get<\/h4>\n\n\n\n<p>Whenever tutorials tell you to install software, they are either using <em>apt<\/em> or <em>apt-get<\/em>, but what is the difference? In essence, for the end user there is none whatsoever. <\/p>\n\n\n\n<p><em>apt<\/em> is a high-level interface for managing packages, which means it is just easier to use and does not have more specialized functions that <em>apt-get<\/em> has. If you are just installing and removing software <em>apt<\/em> and <em>apt-get<\/em> can be used interchangeably. <\/p>\n\n\n\n<div style=\"height:56px\" aria-hidden=\"true\" class=\"wp-block-spacer\"><\/div>\n\n\n\n<h4 class=\"wp-block-heading\">Conclusion<\/h4>\n\n\n\n<p>Using apt is quite simple, however, it is vital to know how to properly install and remove software from your server. After all, without software your server will be quite useless.<\/p>\n\n\n\n<p>On the other hand, if you no longer need a certain package it is best to remove it. Any software that you introduce on your server is a potential security risk. You might not be aware of a proverbial &#8220;hole&#8221; in a particular program, which can be exploited by malicious parties. To mitigate such risk simply uninstall everything you no longer need. If not for security reasons alone, which should be reason enough, then for the sake of disk space as well.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>What is APT? APT stands for Advanced Packaging Tool \u2013 it is a collection of tools that help with package management. Software written for Linux and available to the end-user via repository is called a package. It does not matter&hellip; <\/p>\n","protected":false},"author":1,"featured_media":0,"parent":1026,"menu_order":3,"comment_status":"open","ping_status":"closed","template":"","meta":{"footnotes":""},"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v23.5 - https:\/\/yoast.com\/wordpress\/plugins\/seo\/ -->\n<title>APT \u2013 managing software made easy &#8212; Code Done Right!<\/title>\n<meta name=\"description\" content=\"In order to install anything on your machine, you need to know why. Enter apt \u2013 Advanced Packaging Tool. Learn how to install software!\" \/>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/codedoneright.eu\/?page_id=1616\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:title\" content=\"APT \u2013 managing software made easy &#8212; Code Done Right!\" \/>\n<meta name=\"twitter:description\" content=\"In order to install anything on your machine, you need to know why. Enter apt \u2013 Advanced Packaging Tool. Learn how to install software!\" \/>\n<meta name=\"twitter:label1\" content=\"Est. reading time\" \/>\n\t<meta name=\"twitter:data1\" content=\"5 minutes\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\/\/schema.org\",\"@graph\":[{\"@type\":\"WebPage\",\"@id\":\"https:\/\/codedoneright.eu\/?page_id=1616\",\"url\":\"https:\/\/codedoneright.eu\/?page_id=1616\",\"name\":\"APT \u2013 managing software made easy &#8212; Code Done Right!\",\"isPartOf\":{\"@id\":\"https:\/\/codedoneright.eu\/#website\"},\"datePublished\":\"2021-02-01T02:57:23+00:00\",\"dateModified\":\"2021-02-01T02:57:23+00:00\",\"description\":\"In order to install anything on your machine, you need to know why. Enter apt \u2013 Advanced Packaging Tool. Learn how to install software!\",\"breadcrumb\":{\"@id\":\"https:\/\/codedoneright.eu\/?page_id=1616#breadcrumb\"},\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\/\/codedoneright.eu\/?page_id=1616\"]}]},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\/\/codedoneright.eu\/?page_id=1616#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Home\",\"item\":\"https:\/\/codedoneright.eu\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"Linux\",\"item\":\"https:\/\/codedoneright.eu\/?page_id=1026\"},{\"@type\":\"ListItem\",\"position\":3,\"name\":\"APT \u2013 managing software\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\/\/codedoneright.eu\/#website\",\"url\":\"https:\/\/codedoneright.eu\/\",\"name\":\"Code Done Right!\",\"description\":\"Raspberry Pi server guides\",\"publisher\":{\"@id\":\"https:\/\/codedoneright.eu\/#\/schema\/person\/50378701e349dbd5d40888bc5b532568\"},\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\/\/codedoneright.eu\/?s={search_term_string}\"},\"query-input\":{\"@type\":\"PropertyValueSpecification\",\"valueRequired\":true,\"valueName\":\"search_term_string\"}}],\"inLanguage\":\"en-US\"},{\"@type\":[\"Person\",\"Organization\"],\"@id\":\"https:\/\/codedoneright.eu\/#\/schema\/person\/50378701e349dbd5d40888bc5b532568\",\"name\":\"CodeDoneRight\",\"image\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\/\/codedoneright.eu\/#\/schema\/person\/image\/\",\"url\":\"https:\/\/codedoneright.eu\/wp-content\/uploads\/www_icon.png\",\"contentUrl\":\"https:\/\/codedoneright.eu\/wp-content\/uploads\/www_icon.png\",\"width\":120,\"height\":120,\"caption\":\"CodeDoneRight\"},\"logo\":{\"@id\":\"https:\/\/codedoneright.eu\/#\/schema\/person\/image\/\"},\"sameAs\":[\"https:\/\/codedoneright.eu\"]}]}<\/script>\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"APT \u2013 managing software made easy &#8212; Code Done Right!","description":"In order to install anything on your machine, you need to know why. Enter apt \u2013 Advanced Packaging Tool. Learn how to install software!","robots":{"index":"index","follow":"follow","max-snippet":"max-snippet:-1","max-image-preview":"max-image-preview:large","max-video-preview":"max-video-preview:-1"},"canonical":"https:\/\/codedoneright.eu\/?page_id=1616","twitter_card":"summary_large_image","twitter_title":"APT \u2013 managing software made easy &#8212; Code Done Right!","twitter_description":"In order to install anything on your machine, you need to know why. Enter apt \u2013 Advanced Packaging Tool. Learn how to install software!","twitter_misc":{"Est. reading time":"5 minutes"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"WebPage","@id":"https:\/\/codedoneright.eu\/?page_id=1616","url":"https:\/\/codedoneright.eu\/?page_id=1616","name":"APT \u2013 managing software made easy &#8212; Code Done Right!","isPartOf":{"@id":"https:\/\/codedoneright.eu\/#website"},"datePublished":"2021-02-01T02:57:23+00:00","dateModified":"2021-02-01T02:57:23+00:00","description":"In order to install anything on your machine, you need to know why. Enter apt \u2013 Advanced Packaging Tool. Learn how to install software!","breadcrumb":{"@id":"https:\/\/codedoneright.eu\/?page_id=1616#breadcrumb"},"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/codedoneright.eu\/?page_id=1616"]}]},{"@type":"BreadcrumbList","@id":"https:\/\/codedoneright.eu\/?page_id=1616#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https:\/\/codedoneright.eu\/"},{"@type":"ListItem","position":2,"name":"Linux","item":"https:\/\/codedoneright.eu\/?page_id=1026"},{"@type":"ListItem","position":3,"name":"APT \u2013 managing software"}]},{"@type":"WebSite","@id":"https:\/\/codedoneright.eu\/#website","url":"https:\/\/codedoneright.eu\/","name":"Code Done Right!","description":"Raspberry Pi server guides","publisher":{"@id":"https:\/\/codedoneright.eu\/#\/schema\/person\/50378701e349dbd5d40888bc5b532568"},"potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/codedoneright.eu\/?s={search_term_string}"},"query-input":{"@type":"PropertyValueSpecification","valueRequired":true,"valueName":"search_term_string"}}],"inLanguage":"en-US"},{"@type":["Person","Organization"],"@id":"https:\/\/codedoneright.eu\/#\/schema\/person\/50378701e349dbd5d40888bc5b532568","name":"CodeDoneRight","image":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/codedoneright.eu\/#\/schema\/person\/image\/","url":"https:\/\/codedoneright.eu\/wp-content\/uploads\/www_icon.png","contentUrl":"https:\/\/codedoneright.eu\/wp-content\/uploads\/www_icon.png","width":120,"height":120,"caption":"CodeDoneRight"},"logo":{"@id":"https:\/\/codedoneright.eu\/#\/schema\/person\/image\/"},"sameAs":["https:\/\/codedoneright.eu"]}]}},"_links":{"self":[{"href":"https:\/\/codedoneright.eu\/index.php?rest_route=\/wp\/v2\/pages\/1616"}],"collection":[{"href":"https:\/\/codedoneright.eu\/index.php?rest_route=\/wp\/v2\/pages"}],"about":[{"href":"https:\/\/codedoneright.eu\/index.php?rest_route=\/wp\/v2\/types\/page"}],"author":[{"embeddable":true,"href":"https:\/\/codedoneright.eu\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/codedoneright.eu\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=1616"}],"version-history":[{"count":12,"href":"https:\/\/codedoneright.eu\/index.php?rest_route=\/wp\/v2\/pages\/1616\/revisions"}],"predecessor-version":[{"id":1628,"href":"https:\/\/codedoneright.eu\/index.php?rest_route=\/wp\/v2\/pages\/1616\/revisions\/1628"}],"up":[{"embeddable":true,"href":"https:\/\/codedoneright.eu\/index.php?rest_route=\/wp\/v2\/pages\/1026"}],"wp:attachment":[{"href":"https:\/\/codedoneright.eu\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=1616"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}