{"id":797,"date":"2021-01-25T16:46:24","date_gmt":"2021-01-25T15:46:24","guid":{"rendered":"https:\/\/nguenkam.com\/blog\/?p=797"},"modified":"2021-01-25T16:48:14","modified_gmt":"2021-01-25T15:48:14","slug":"install-manage-package-with-linux","status":"publish","type":"post","link":"https:\/\/nguenkam.com\/blog\/index.php\/2021\/01\/25\/install-manage-package-with-linux\/","title":{"rendered":"Install &#038; manage Package with Linux"},"content":{"rendered":"\n<p>When you are on Windows and want to download a new program, what do you do?<br>Usually a little research on a search engine, a look at the download sites like telecharger.com, clubic.com\u2026 and you find what you are looking for. You get an installer, you do &#8220;Next&#8221;, &#8220;Next&#8221;, &#8220;Next&#8221;, &#8220;Finish&#8221; and it&#8217;s installed. Sometimes you have to answer a little technical questions like &#8220;In which directory do you want to install this program?&#8221; .<\/p>\n\n\n\n<p>Under Linux (and in particular under Ubuntu), it does not work at all like that: it is even simpler. Better: you will quickly realize that it is a real pleasure to install new programs and that it is even one of the strengths of a system like Ubuntu compared to Windows.<br><\/p>\n\n\n\n<h5>Packages and their dependencies<\/h5>\n\n\n\n<p>First of all, remember what we are going to do here only concerns Linux distributions based on Debian (Ubuntu is one of them).<br>Indeed, the installation of programs works differently from one distribution to another. This is precisely one of the major differences between distributions.<\/p>\n\n\n\n<p>In Windows, you know what are called &#8220;Installers&#8221;. Typically, these are launchable.exe files that run and extract the program files to a Program Files folder.<br>Example: The installation program for the Trackmania Nations game on Windows is shown in the following figure.<\/p>\n\n\n\n<figure class=\"wp-block-image\"><img src=\"https:\/\/user.oc-static.com\/files\/108001_109000\/108262.png\" alt=\"Installation de programme sous Windows\"\/><\/figure>\n\n\n\n<p>Under Ubuntu, we don&#8217;t have installation programs; we have what we call packages.<br>A package is a kind of zipped folder that contains all of the program files. It comes in the form of a.deb file, in reference to DEBian. It contains all the instructions needed to install the program.<\/p>\n\n\n\n<p>A deb package is kind of like an installer.exe in Windows with some fews differences.<\/p>\n\n\n\n<ul><li>there is a dependency management of the program;<\/li><li>you don&#8217;t need to do a search engine to find un.deb. All of the files are gathered in the same place on a single server called a repository.<\/li><\/ul>\n\n\n\n<h5>Dependencies<\/h5>\n\n\n\n<p>It is very rare that a program can run on its own under Linux. Quite often it uses other programs or other &#8220;pieces of programs&#8221; called libraries. We say that programs depend on other programs to function: they have dependencies.<\/p>\n\n\n\n<p><br>You have certainly encountered this problem a bit in Windows before. For example, when you install a game, you are told &#8220;You must install Direct X before you can play this game&#8221;.<\/p>\n\n\n\n<p>Fortunately, the Debian package system is smart. Each package indicates which other packages it depends on. This allows the system to go and recover missing dependencies automatically if needed.<br>So you just have to say &#8220;I want to install Nano&#8221; and the system will look for all the missing dependencies on its own!<\/p>\n\n\n\n<h4><span class=\"has-inline-color has-vivid-cyan-blue-color\">Installing package<\/span><\/h4>\n\n\n\n<p>We generally have to follow three steps to download a package:<\/p>\n\n\n\n<ul><li><strong>sudo apt update<\/strong> (optional): to update our cache if it is not already done;<\/li><li><strong>sudo apt search mypackage<\/strong> (optional): to search for the package we want to download if we don&#8217;t know its exact name;<\/li><li><strong>sudo apt install mypackage<\/strong>: to download and install our package.<\/li><\/ul>\n\n\n\n<pre class=\"wp-block-preformatted\">If you want a fuller description of a package, \nuse<strong> sudo apt show packagename<\/strong>. Example:\napt-cache show lbreakout2.<\/pre>\n\n\n\n<h4><span class=\"has-inline-color has-vivid-cyan-blue-color\">remove a package<\/span><\/h4>\n\n\n\n<p><br>If you want to uninstall a package, you can use the command <strong>sudo apt remove packagename<\/strong><\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>sudo apt remove lbreakout2<\/code><\/pre>\n\n\n\n<p>The package will then be uninstalled from your computer.<br>However, this does not remove package dependencies that are no longer needed. To ask apt to also remove unnecessary dependencies, we use <strong>autoremove<\/strong>:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>sudo apt autoremove lbreakout2<\/code><\/pre>\n\n\n\n<h4><span class=\"has-inline-color has-vivid-cyan-blue-color\">update all packages<\/span><\/h4>\n\n\n\n<p>Another particularly great feature of apt is its ability to update all the packages installed on your system at once. The program will look for new versions of all your programs and update them if a new version is available:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>sudo apt upgrade\nor \nsudo apt list --upgradable\n<\/code><\/pre>\n\n\n\n<pre class=\"wp-block-preformatted\">\nRemember to make first \"<strong>sudo apt update<\/strong>\" to update the package\n cache on your machine before running an upgrade.\nIndeed, apt compares the version of your installed packages with\n those present in the cache. If your cache is \"old\" apt will say \n\"Oh bah, there is nothing new, no need for an update\". So be sure \nto  make \"<strong>sudo apt update<\/strong>\" regularly to be 100% sure your cache \nis up to date.<\/pre>\n\n\n\n<p><\/p>\n","protected":false},"excerpt":{"rendered":"<p>When you are on Windows and want to download a new program, what do you do?Usually a little research on a search engine, a look at the download sites like telecharger.com, clubic.com\u2026 and you find what you are looking for. You get an installer, you do &#8220;Next&#8221;, &#8220;Next&#8221;, &#8220;Next&#8221;, &#8220;Finish&#8221; and it&#8217;s installed. Sometimes you [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":[],"categories":[1],"tags":[194,171,196,193,148,197,198],"_links":{"self":[{"href":"https:\/\/nguenkam.com\/blog\/index.php\/wp-json\/wp\/v2\/posts\/797"}],"collection":[{"href":"https:\/\/nguenkam.com\/blog\/index.php\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/nguenkam.com\/blog\/index.php\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/nguenkam.com\/blog\/index.php\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/nguenkam.com\/blog\/index.php\/wp-json\/wp\/v2\/comments?post=797"}],"version-history":[{"count":4,"href":"https:\/\/nguenkam.com\/blog\/index.php\/wp-json\/wp\/v2\/posts\/797\/revisions"}],"predecessor-version":[{"id":801,"href":"https:\/\/nguenkam.com\/blog\/index.php\/wp-json\/wp\/v2\/posts\/797\/revisions\/801"}],"wp:attachment":[{"href":"https:\/\/nguenkam.com\/blog\/index.php\/wp-json\/wp\/v2\/media?parent=797"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/nguenkam.com\/blog\/index.php\/wp-json\/wp\/v2\/categories?post=797"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/nguenkam.com\/blog\/index.php\/wp-json\/wp\/v2\/tags?post=797"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}