You are on page 1of 21

11001010110001101010

Module 4 - Linux OS

Chapter 4.7 - Linux Package Managers


11001010101010

11001010101010
● APT
● Snap
● Flatpak

12 July 2023

1
11001010110001101010
11001010110001101010

APT- Advanced Packaging Tool


APT is the default management system that was developed for Debian, since Ubuntu and other similar operating
systems based on it, thus all use the APT.

We can use APT to search for program packages to install them or bring the whole system up to date. It is not just
11001010101010

11001010101010
limited to this, a variety of tasks can be done using it, and here some common examples of how to use the APT
Ubuntu package manager on the command line.

2
11001010110001101010
11001010110001101010

apt-get – package and source management


In the old systems such as Ubuntu 20.04, the apt was used along with get, however, in
the latest version, we don’t need to use it for downloading and installing various
packages.
11001010101010

11001010101010
3
11001010110001101010
11001010110001101010

Here are examples to use it

● For updating repo- sudo apt update


● To upgrade- sudo apt upgrade
11001010101010

11001010101010
● Install software from repo– Syntax: [sudo] apt-get [option] Command [packg1] [packg2]
sudo apt package-name, example sudo apt install vlc

4
11001010110001101010
11001010110001101010

Apt-get upgrade vs Apt-get update


Both apt-get update and apt-get upgrade are used to install packages in Linux, but they are used for
different purposes.

The command apt-get update is used to update the package index files on the system, which contain
information about available packages and their versions. It downloads the most recent package
11001010101010

11001010101010
information from the sources listed in the "/etc/apt/sources.list" file that contains your sources list. It is
advised to run apt-get update frequently in order to ensure that the system is aware of the latest
available package updates.

OTOH, apt-get upgrade is used to update installed packages to the most recent version. To identify which
packages require an upgrade, "apt-get update" is used to gather the necessary information. The "apt-get
upgrade" program downloads and installs the most recent packages, replacing any earlier versions that
were already on your system.

In a nutshell, "apt-get update" updates the package index files, whereas "apt-get upgrade" upgrades the
actual packages installed on your system.

Using apt-get update and apt-get upgrade is essential for keeping your Linux system up-to-date with the
latest package releases.

5
11001010110001101010
11001010110001101010

How to install an App?

In this we are going to install firefox package in our Debian-base


Linux operating system (In this case we are executing this command
in Ubuntu)
11001010101010

11001010101010
sudo apt-get install firefox
sudo apt-get remove firefox

6
11001010110001101010
11001010110001101010

Remove Unused Packages (apt autoremove)

Whenever a new package that depends on other packages is installed


on the system, the package dependencies will be installed too. When
the package is removed, the dependencies will stay on the system. This
11001010101010

11001010101010
leftover packages are no longer used by anything else and can be
removed.
To remove the unneeded dependencies use the following command:
sudo apt autoremove

7
11001010110001101010
11001010110001101010

Listing Packages (apt list)


The list command allows you to list the available, installed and, upgradeable packages.
To list all available packages use the following command:
11001010101010

11001010101010
sudo apt list

The command will print a list of all packages, including information about the versions and architecture of
the package. To find out whether a specific package is installed, you can filter the output with the grep
command.

sudo apt list | grep package_name

8
11001010110001101010
11001010110001101010

To list only the installed packages type:


sudo apt list --installed

Getting a list of the upgradeable packages may be useful before actually upgrading the packages:
sudo apt list --upgradeable
11001010101010

11001010101010
Searching Packages (apt search)
This command allows you to search for a given package in the list of the available packages:
sudo apt search package_name
If found, the command will return the packages which name matches the search term.

9
11001010110001101010
11001010110001101010

apt-cache – Show info about packages and sources


Running apt-cache will not affect or change anything in the system.
Its only purpose is to show the data in the package cache or
package metadata. The package cache is the internal database that
11001010101010

11001010101010
stores information about all available packages.

apt-cache [Option] commando [Package-name]

Example– apt-cache showpkg vlc

10
11001010110001101010
11001010110001101010

apt-search- Search packages in the repos


Many times we want to install some package but we don’t know whether that
is available in the official repo or under exactly what file-name of it.
11001010101010

11001010101010
For example, we want to install the KDE connection app that is available in
the official Ubuntu repo but how do we know the exact package name to use
with the apt command. Thus, we will search it:

apt search "ssh"

11
11001010110001101010
11001010110001101010

apt-mark – keep the current version


When we run the update command, the process updates all the installed packages,
however, in case we don’t want to do update some particular program then there is
an apt-mark command that helps us to do that. For example- we want to hold the
11001010101010

11001010101010
updates for the installed Firefox version, so the syntax will be:

sudo apt-mark hold firefox

And to unhold it use:

sudo apt-mark unhold firefox

12
11001010110001101010
11001010110001101010

2. Snap- Universal Package Manager

Snap or Snappy is another Ubuntu Package Manager, also now


available by default on all the latest versions of Ubuntu. It is a
11001010101010

11001010101010
software deployment and package management system developed
by Canonical to provide a universal package management platform
for all major Linux distros. Primarily it meant for a server or cloud
environment and also for the Internet of Things. However, now it
can be found in the desktop versions and even integrated into the
GUI Software Manager of Ubuntu.

13
11001010110001101010
11001010110001101010
sudo snap install package-name– To install packages from Snap

sudo snap remove package-name– To remove the installed package

snap list --all – Will show all installed SNAP programs or packages

snap changes – Shows the progress of the installations, reinstallations, etc. of snaps.
11001010101010

11001010101010
sudo snap refresh– command refresh updates all snaps:

sudo snap refresh package-name – You can also specifically update individual
snaps.

snap list – lists the installed snaps. The name, version, revision, track/channel,
developer, and notes of the snap are displayed by default.

snap --help – List commands related to SNAP

14
11001010110001101010
11001010110001101010

3. Flatpak – Package manager


Flatpak as Ubuntu Package Manager is an alternative option to snap apps, if you don’t want to
use SNAP then this package manager is a good option. Just like SNAP, we can also install
various software from its library without making any conflict, even if that same software has
been installed on the system using the default APT manager. Flatpak places all its required
11001010101010

11001010101010
binaries, libraries, configuration files, and other files in a directory /var/lib/flatpak/app.
Thus, it can be install and use on various kinds of popular Linux distributions without any
further adjustments. All the major open-source applications are available in its repository
called FlatHub.

15
11001010110001101010
11001010110001101010

3. Flatpak – Package manager

sudo flatpak update – Update installed programs

sudo flatpak install pacakge-name – To install packages available in


11001010101010

11001010101010
FlaHub.

sudo flatpak uninstall pacakge-name- Uninstall apps

flatpak list– List installed programs

Here is the official documentation to know more about – Flatpak.

16
11001010110001101010
11001010110001101010

How to install and Use Flatpak on Ubuntu 22.04

Flatpak repository is already included in the Ubuntu 22.04 repository


list, thus making the installation pretty simple and easier to follow. The
below steps will let you install Flatpak on Ubuntu 22.04.
11001010101010

11001010101010
Step 1: Updating the Packages
First, ensure that Ubuntu packages are up to date and that the below
command will be used for this purpose.

$ sudo apt update

17
11001010110001101010
11001010110001101010

How to install and Use Flatpak on Ubuntu 22.04

Step 2: Installing Flatpak


After the update, you can install the Flatpak on Ubuntu 22.04 using the following
command.
11001010101010

11001010101010
$ sudo apt install flatpak

To check the Flatpak version, you can use the following command.

$ flatpak --version

18
11001010110001101010
11001010110001101010

How to use Flatpak on Ubuntu 22.04

After successfully installing Flatpak on Ubuntu 22.04, it’s now time to tell you how you
can use this tool to download different packages or software.
11001010101010

11001010101010
First enable the Flathub (a popular destination for searching the application) using the
following command.

$ flatpak remote-add --if-not-exists flathub


https://flathub.org/repo/flathub.flatpakrepo

19
11001010110001101010
11001010110001101010

How to use Flatpak on Ubuntu 22.04

Once the Flathub is enabled, you can then install the application through the following
command.
11001010101010

$ flatpak install <Application_name>

11001010101010
Just replace the “Application_name” with the name of the application you want to install. In
our case, we are installing Telegram through Flatpak using the following command.

$ flatpak install telegram


When you run the above command, it will provide you with two application IDs and you have
to pick one for installation.

$ flatpak run app/org.telegram.desktop

20
11001010110001101010
11001010110001101010

Uninstalling Application through Flatpak

To uninstall the application from Flatpak, you will again need to use the
application ID in the following command.
11001010101010

11001010101010
$ flatpak uninstall <Application_ID>
To uninstall Telegram:

$ flatpak uninstall app/org.telegram.desktop

21
11001010110001101010

You might also like