0% found this document useful (0 votes)
4 views

Module_4a_Installing and Updating_Software

Uploaded by

juliopetronilo
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
4 views

Module_4a_Installing and Updating_Software

Uploaded by

juliopetronilo
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 23

INFO-3182- Operating systems - Linux

Module 4a Installing and Updating


Software
Introduction

This document looks at methods for installing and updating software on Linux systems. There are
several methods for installing software on Linux systems, including:

• Installing from the distribution’s on-line package repositories.


• Installing from third party on-line package repositories.
• Installing using packages downloaded from a third-party website.
• Installing using archive files (zip, tar.gz, etc.) downloaded from a third-party website.
• Installing from source code obtained as a package from the Linux distribution’s on-line
repositories.
• Installing from source code obtained from a third-party website
• Creating and deploying an application on the local system

After installing software, the approaches to keeping them up to date are dependent upon the methods
used to install them.

This document does not look at installing from source code.

NOTE: The commands used in this document have many sub-commands and parameters. Only some of
them are discussed here. See the help documentation for each command for more details.

Working with Linux distribution repositories.

As noted in earlier modules, CentOS Stream 9 uses the rpm package manager and Ubuntu 24.04 uses
both dpkg and snap. Since rpm and dpkg are both complex to use and not very flexible, most
administrators use the dnf and apt helper tools instead. The snap package manager is newer and, in
some ways, simpler to use but its repository (known as the snap store) has mostly specialized software
packages (known as snaps) at the present time.

For systems with graphical desktops, the GUI tools discussed in earlier modules can be used as an
alternative to the dnf and apt commands. These GUI tools are not covered in this document as their
use is not difficult once dnf and apt are known.

Page 1 of 23
INFO-3182- Operating systems - Linux

Installing software from the CentOS Stream 9 package repositories using dnf.

Installing software from the default CentOS Stream 9 repositories using dnf is straightforward when the
package names are known. For example, to install the basic PHP interpreter and related files use:
sudo dnf install php

as shown in Figure 1. While the command only specifies the php package, dnf automatically selects any
packages that the php package depends on for installation, if they are not already installed. Instead of
just installing one package, Figure 1 shows that a total of 20 packages will be installed requiring 44 MB
of disk space.

Figure 1 Screenshot of the dnf command being used to install the basic php package. Any packages it depends on are
automatically selected for installation as well.

There are ways to search the CentOS Stream 9 repositories and the contents of the packages in the
repositories. This is useful when the exact name of a package is not known, or when looking for a

Page 2 of 23
INFO-3182- Operating systems - Linux

specific program to install. As an example, assume that gvim, the graphical version of the vim editor,
needs to be installed on a system.

Figure 2 shows the first attempts to find the gvim command. The first uses the command
sudo dnf list | grep gvim

to search for the command as a package name. No results are produced meaning that there is no
package with gvim in its name. The second command in Figure 2 lists all packages with vim in their
names
sudo dnf list | grep vim

This command shows that there are five packages with vim in their names, but no information is given
about whether the packages are installed or not. Nor is there any information about what each package
has in it.

Figure 2 Screenshot showing the dnf command being used to try to find the gvim command as a package name. After that, a
listing of all packages with vim in their names is obtained.

Figure 3 shows two commands performing more selective searches for packages with vim in their
names. These commands are:
sudo dnf list installed | grep vim
sudo dnf list available | grep vim

The results of these two commands show that four of the five packages identified previously are
installed and one is not. There is still no information on what is inside each package.

Page 3 of 23
INFO-3182- Operating systems - Linux

Figure 3 Screenshot showing the execution of the dnf list installed and dnf list available commands looking for packages with
vim in their names. There are four installed packages and one available package.

Figure 4 Screenshot showing the dnf provides command being used to search for packages with a file named gvim in them.
Multiple versions of the vim-X11 package are listed.

At this point, an educated guess might be made that the gvim program is in the package that is not
installed. This is true, but another search can be used to find out for sure.

The dnf command has other search capabilities in it, including the ability to search for the names of
files inside a package. The command to search for the gvim program file is:
sudo dnf provides gvim

Figure 4 shows this command and its output. Five versions of the vim-X11 package are shown as having
the gvim file in them. It is not uncommon to have multiple versions of the same package listed in the
results of this search. It is also common to have multiple different packages listed. In the case of multiple
versions of the same package, it is safe to assume that the correct file has been found. However, when

Page 4 of 23
INFO-3182- Operating systems - Linux

multiple different packages are listed, further investigation is needed to identify the package with the
correct file.

After finding the package with the needed file in it, install the package. For the vim-X11 package the
command is:
sudo dnf install vim-X11

As shown in Figure 5. The vim-X11 package has no dependencies on packages that are not already
installed, so no dependencies are listed in the Figure.

Figure 5 Screenshot showing the dnf install command being used to add the vim-X11 package to the system.

Updating software from the CentOS Stream 9 package repositories using dnf.

Updating software that was installed from the CentOS Stream 9 repositories or from any other
repository that has been enabled on a CentOS Stream 9 system requires the execution of a single
command:
Sudo dnf upgrade -y

This command automatically updates the package database on the local system, then downloads and
installs any available updates for all packages. Leaving off the -y parameter causes dnf to prompt the
user for confirmation of the update and for any updated PGP keys used to sign packages.

NOTE: There is an alias dnf update for the dnf upgrade command. While this alias still works and
is widely used (including in some of the content of this course), it has been deprecated. Get into the
habit of using dnf upgrade.

It is possible to specify one or more packages to upgrade instead of upgrading all packages on a system.
For example:
sudo dnf update vim-X11

Page 5 of 23
INFO-3182- Operating systems - Linux

Checks for updates to the vim-X11 package. If any updates are available, the user will be prompted to
confirm that the update is to be performed.

Figure 6 Screenshot of the dnf update command trying to update the vim-X11 package. The package is up to date, so there is
nothing to do.

There is also a dnf command that checks for updates without performing the updates. This command
is:
sudo dnf check-update

This command checks for new versions of packages that are already on the system. The output of this
command always includes the timestamp of the last time the package database was updated. If there
are any updates available, they are listed as part of the output.

This command is useful for automating the system update process. The output of the command can be
discarded, and its exit code checked instead. The exit codes produced are:

• 0 – The command completed successfully but there are not updates available.
• 100 – The command completed successfully. Updates are available.
• 1 – An error occurred that was handled by dnf.
• 3 – An unknown error occurred that could not be handled by dnf.

CAUTION: dnf check-update reports all available updates, but dnf upgrade may not install all
of them. This is because dnf upgrade includes filters to ensure that only fully released packages are
updated. It is also possible to configure dnf upgrade (and other commands) to ignore specific
packages to avoid conflicts with manually installed software.

There is an alias for dnf check-update named dnf check-upgrade.

Removing packages from a CentOS Stream 9 system using dnf.

It is sometimes necessary to remove (delete) packages from a CentOS Stream 9 system. The easiest way
to do this is to use the dnf command. For example, to delete the vim-X11 package and any packages
that depend on it (none in this case) use the command:

Page 6 of 23
INFO-3182- Operating systems - Linux

sudo dnf remove vim-X11

Figure 7 shows this command being used. No other packages depend on the vim-X11 package, so none
are listed for removal at the same time.

Figure 7 Screenshot showing the vim-X11 package being removed from a system.

There are two special cases for the dnf remove command worth noting:

• sudo dnf remove –duplicates This command removes duplicate versions of packages
from the system keeping only the newest version of each package.

• sudo dnf remove –oldinstallonly This command removes old versions of packages,
such as kernel packages, which are only ever installed, never updated.

Both the above commands are useful for reclaiming disk space.

Cleaning up cached files related to dnf.

The dnf command uses caches to store the package files it downloads and metadata about those files.
Over time, these caches can grow large, consuming valuable disk space. It is possible to clean these
caches using the dnf command. One way to clean the caches is to use the command:
sudo dnf clean all

Figure 8 shows this command in action. The output of the command reports that 21 cache files were
removed.

Page 7 of 23
INFO-3182- Operating systems - Linux

Figure 8 Screenshot of the dnf command being used to clean all its caches.

Using non-default repositories.

By default, dnf is configured to use the baseos (base CentOS Stream 9 packages), appstream (application
packages), and extras-common (optional but often used packages) repositories provided by the
developers of CentOS Stream 9. These are the repositories that contain production-ready packages.
Along with these three repositories, other packages are already defined in the
/etc/yum.repos.d/centos.repo and /etc/yum.repos.d/centos-addons.repos files. These additional
repositories are used to obtain the source code for packages, debugging versions of packages,
development versions of packages (not production ready) and some special purpose packages.

Figure 9 shows the baseos repository definition in the /etc/yum.repos.d/centos.repo file. The last item
in the configuration is enabled=1, meaning that this repository is being used whenever dnf is invoked.
The baseos, appstream, and extras-common repositories are all enabled and should not be disabled. The
remaining repositories are disabled (enabled=0) and in most situations should not be enabled on
production systems as they are really for developers and experimenters.

Figure 9 Screenshot showing the baseos repository definition in the /etc/yum.repos.d/centos.repo file.

There are more repositories than these available for CentOS Stream 9. Some of them, such as Extra
Packages for Enterprise Linux (EPEL) have packages in one of the default repositories that install and
enable their definitions. The epel-release package is in the extras-common repository. Adding
repositories using packages is just the same as installing any other package. For example:
sudo dnf install epel-release

as shown in Figure 10.

Page 8 of 23
INFO-3182- Operating systems - Linux

Figure 10 Screenshot showing the epel-release package being installed to define and enable the EPEL repository.

Many third-party software developers have their own repositories available, but they do not have
packages in the default repositories to add them. Instead, system administrators need to add them to
the set of available repositories manually. The procedure to follow depends on the developer. Docker is
an example of a developer that provides repositories that must be configured this way (demonstrated
on ubuntu 24.04 below).

Searching for Ubuntu packages and their contents

NOTE: Before attempting to do any package related operations on Ubuntu 24.04, update the package
database using the command:
sudo apt-get update

Ubuntu 24.04 does not include a single tool like dnf that allows a user to perform all package
management operations. Instead, multiple tools must be used.

To list the packages that are already installed on an Ubuntu 24.04 system, the Debian Package Manager
(dpkg) command is used. The command is:
sudo dpkg -l

Figure 11 shows the first page of output from this command. The command itself is not shown because
when used this way, dpkg automatically uses scrollable paging functionality like that of the less
command. The output shown in Figure 11 includes the name, version and brief description of each
package. It also includes the hardware architecture for which the package is available and some status
information. In the Figure, the hardware architecture column shows either amd64 (64-bit AMD and Intel
hardware) and all (all supported hardware architectures). Ubuntu supports several hardware
architectures, only the one for the current system and all will be shown on any given ubuntu system.

Page 9 of 23
INFO-3182- Operating systems - Linux

The status information is shown in the first three characters of each line of output. The first character
indicates the desired state of the package identified on that line. The second character identifies the
actual state of the package and the third is either blank (no error) or an error condition indicator. For
successfully installed packages, the desired and actual states should both be ‘i’ meaning that the
package was successfully installed and is in its normal condition. Any other values in these two-character
positions need to be investigated unless an update or installation is in progress.

Figure 11 Screenshot showing the first page of output from the dpkg -l command.

To display information about an installed package, use the dpkg -s command. For example, to get
information on the apt package use:
sudo dpkg -s apt

Figure 12 shows the command and its output.

Figure 12 Screenshot of the dpkg -s command displaying information about the apt package.

Page 10 of 23
INFO-3182- Operating systems - Linux

Another command that displays information about packages is apt-cache showpkg. This
command works whether a package is installed or not. The structure of the output is different from that
produced by dpkg -s, but much of the content is the same. For example,
sudo apt-cache showpkg vim-gui-common

Figure 13 shows this command and its output. The package is not currently installed.

Figure 13 Screenshot of the apt-cache showpkg command being used to display information about the vim-gui-common
package which is not currently installed.

If all that is needed is the complete package name when part of the name is known, the apt-cache
dumpavail command is a good choice. Using this command in a pipeline with two calls to the grep
command produces simple easy to read results, albeit lengthy in some cases. For example, the following
command lists all package with vim- in their names.
sudo apt-cache dumpavail | grep Package: | grep vim-

Figure 14 shows this command, and the first few lines of output produced. The first grep command is
used to select only the lines of output that contain package names. The second grep command finds
package names with the required string in them.

Page 11 of 23
INFO-3182- Operating systems - Linux

Figure 14 Screenshot of the apt-cache dumpavail command in a pipeline with two calls to grep looking for packages whose
names contain vim-.

Unlike dnf, there is not a single apt tool that provides a method for finding out which package a given
file is in. Four of the ways that a file’s package may be found are:

• dpkg -S – (uppercase S) This command searches through packages known to dpkg. The fully
qualified file name should be used to keep the length of the output down to a manageable size.
• apt-cache search – This command searches all available packages, installed or not using
a full text search algorithm. This command will usually find the file if it exists, but the output can
be very long and complex to read.
• apt-file search – this command is in an optional package that must be installed before it
can be used. It also uses a separate data cache from dpkg and the other apt tools which must be
maintained manually.
• If the file is a program, try running it, if it is not installed Ubuntu contains functionality that will
suggest the packages that it can be found in.

Figure 15 shows the second and fourth of these methods being used to find the package for the gvim
program. Interestingly, the output is somewhat different, apt-cache search found the vim-gui-
common package in addition to the three that were also found by trying to run the program. This is
another case where further investigation is probably needed.

Page 12 of 23
INFO-3182- Operating systems - Linux

Figure 15 Screenshot showing the apt-cache search command being used to find the package containing the gvim program. Also
shown are the suggested packages provided when attempting to run the gvim program.

It should be noted that none of the packages suggested above for the gvim program have the same
name as the package found on CentOS Stream 9. This is a common occurrence. Every Linux distribution
has its own way of assembling and naming packages.

Installing software from the Ubuntu 24.04 package repositories using apt.

The apt-get install command is widely used to install software on ubuntu from the online
software repositories. One or more packages can be specified on the command line for installation.
Separate the names of packages with a space.

Continuing with the gvim example above, the vim-gui-common package is installed using the command
apt-get install vim-gui-common

Figure 16 Screenshot of the apt-get install command being used to install the vim-gui-common package.

Page 13 of 23
INFO-3182- Operating systems - Linux

Figure 16 shows the package being installed. The output of the apt-get install command lists the
packages that are to be installed and give some summary information before prompting the user to
confirm in operation is to be performed. Entering ‘y’ and pressing ENTER will install the desired package
and one other package on which it depends.

After installing the vim-gui-common package, the gvim command is available for use, as shown in Figure
17. In the top left of Figure 17, part of the terminal window is shown with the gvim program being
executed. The rest of the screenshot shows the default gvim window. Notice that the prompt is
displayed again after the invocation of gvim. This gvim program is running independently of the terminal
window, so the terminal window can be used for other commands. This is not always the case; some
programs remain attached to the terminal session and do not permit the terminal window to be used
for other purposes.

Figure 17 Screenshot showing the gvim program being started from a terminal window and the gvim program window.

Updating software packages on Ubuntu 24.04 using apt.

The apt-get upgrade or apt-get dist-upgrade commands can be used to update the
software on an Ubuntu system. There are some differences between the two commands. In simple
terms, apt-get dist-upgrade does a more comprehensive update than apt-get upgrade
does, so apt-get dist-upgrade is preferred.

Page 14 of 23
INFO-3182- Operating systems - Linux

Before using apt-get upgrade or apt-get dist-upgrade, always update the package
database using the apt-get update command. This ensures that the latest package information is
available for use when updating software.

Figure 18 shows the apt-get dist-upgrade command being used to update the software on an Ubuntu
system. The cloud-init package is being updated. Notice that some updates are being deferred, this is
common on Ubuntu systems and means that new versions of other packages needed for these to be
updated properly are not yet available. A summary appears at the bottom of the Figure along with a
prompt to confirm the upgrade.

Figure 18 Screenshot of the apt-get dist-upgrade command being used to update the software on a system.

Although not shown in Figure 18, another section of information that is sometimes displayed by both
apt-get upgrade and apt-get dist-upgrade lists packages that are on the system but are no longer
needed. The method for dealing with such packages in discussed later in this document.

After choosing y to perform the upgrade, a list of actions being taken is displayed. If new versions of
services are included in an upgrade, the user is prompted to select which services to restart as part of
the upgrade process. The user can select the services to restart or can skip the restarts and do a reboot
after the upgrade is finished. If a new kernel is installed as part of the upgrade, a reboot is required for
the new kernel to become active.

NOTE: There is some interaction between dpkg, the GUI Software tool and the apt toolset , on one side,
and the snap package manager on the other. Sometimes apt-get upgrade and apt-get dist-upgrade will
fail with errors related to snap. This seems to be more common when using the GUI tools than the apt
tool set. This issue can be resolved by updating the snap packages first and then coming back to the
dpkg-related packages.

Page 15 of 23
INFO-3182- Operating systems - Linux

Removing Ubuntu packages using apt.

The apt-get remove, apt-get purge,apt-get autoremove, and apt-get autopurge


commands can be used to remove packages. The command behaviours are:

• apt-get remove – deletes the software provided by the specified package(s) but leaves
configuration files in place.
• apt-get purge - deletes the software provides by the specified package(s) and their
configuration files.
• apt-get autoremove – deletes packages that have been identified as no longer needed on
the system. These packages are identified during update/upgrade processing, the user does not
specify the packages. Configuration files are not removed.
• apt-get autopurge – same as autoremove, except that configuration files are removed.

To delete the vim-gui-common package installed above, use either:


apt-get remove vim-gui-common

Or
apt-get purge vim-gui-common

depending on whether configuration files are to be retained or not.

Figure 19 shows the vim-gui-common package being purged. Notice that dependencies are also purged.

Figure 19 Screenshot showing the apt-get purge command being used to remove the vim-gui-common package, its
dependencies and configuration files.

Cleaning up apt caches.

The apt-get clean command is used to clean up the apt caches. This includes removing all package
files downloaded by one of the apt tools. This command is particularly important for cloud instances
(virtual machines) to minimize storage costs.

Page 16 of 23
INFO-3182- Operating systems - Linux

Installing packages downloaded from third party websites.

Some software developers do not use Linux distribution repositories or their own repositories. Instead,
users are expected to download package files from the developers’ website. The download may be done
using a graphical web browser (e. g. Firefox), a text-mode web browser (e. g. curl), or a web download
tool (e.g. wget). The wget and curl programs can be used on systems with and without GUI desktops.

This section uses ClamAV as an example. ClamAV is a popular open-source anti-virus tool available for
Linux, Mac OS and Windows systems. It is available in both source code and binary versions from the
ClamAV web site and in binary format from most Linux distribution repositories. Be careful:

• Many Linux distributions are slow in updating the packages in the repositories, meaning that it
may not always be possible to detect the latest viruses using the distribution package version of
ClamAV.
• Installing the ClamAV provided package gets the latest version at the time of installation, but
manual updating is usually necessary.
• Always download ClamAV packages directly to the system where they are to be used. These
packages, especially the source code packages, contain sample (harmless) viruses for testing
purposes. Downloading these packages onto a system with a virus scanner running on it will
often result in a corrupted package because the virus scanner will attempt to clean the package
file.

Figure 20 shows the wget command being used to download the latest version of ClamAV in the .deb
package format. This is the format used by Debian, Ubuntu and most other Debian-family distributions.
The URL for the package file was obtained by visiting the ClamAV download site using Firefox.

Figure 20 Screenshot of the wget command being used to download the deb package for ClamAV onto an Ubuntu system.
Following the download a directory listing is shown that includes the ClamAV package.

The ClamAV package can then be installed by specifying the downloaded file name. For example,

Page 17 of 23
INFO-3182- Operating systems - Linux

sudo apt-get install ./ clamav-1.4.0.linux.x86_64.deb

Figure 21 shows ClamAV being installed on an Ubuntu 24.04 system as the root user rather than using
sudo.

Figure 21 Screenshot showing ClamAV being installed from a downloaded package file instead of the Ubuntu repositories.

ClamAV can be installed on CentOS Stream 9 using this same approach, The package name will end with
.rpm instead and, of course, the dnf command is used instead of apt-get.

NOTE: ClamAV is not yet ready for use. It needs to be configured, and the latest virus signatures loaded.
This is beyond the scope of this lesson.

Using third-party package repositories.

As noted earlier, some software developers, including Docker and Microsoft have their own on-line
repositories for Linux packages. This is an effective way for developers to let users install and update
software as if they were using a distribution’s repositories while maintaining full control of their
products.

This section uses the installation of Docker Engine via Dockers Ubuntu repository as an example.
Docker Engine is a set of command line tools that form the core of all Docker’s container development
and runtime environments. Some components of Docker Engine are widely used with the Kubernetes
container orchestration software.

The information below is based on the instructions at Install Docker Engine on Ubuntu | Docker Docs.

The steps to add the Docker repository and install Docker Engine are:

Page 18 of 23
INFO-3182- Operating systems - Linux

Step 1 – Set up Docker PGP key.

All docker’s packages, like most packages, are signed with the PGP (Pretty Good Protection) private key,
so users of their packages need to add Docker’s public PGP key to their systems apt configuration for the
apt tools to automatically verify packages as they are installed. The commands to add the PGP public key
are:

• sudo apt-get update – Update the local package database.


• sudo apt-get install ca-certificates curl – Install the ca-certificates and curl
packages from the Ubuntu repositories.
• sudo install -m 0755 -d /etc/apt/keyrings – Use the install command to
create a directory to store the PGP public key if it does not already exist.
• sudo curl -fsSL https://download.docker.com/linux/ubuntu/gpg \
-o /etc/apt/keyrings/docker.asc – Download the PGP public key and store it in
the directory created in the previous command.
• sudo chmod a+r /etc/apt/keyrings/docker.asc – Set the permission on the PGP
public key file.

Step 2 – Add the Docker repository to the apt configuration.

Once the PGP public key has been added to the apt configuration, the Docker repository can be added.
This is done using the command pipeline:
echo "deb [arch=$(dpkg --print-architecture) \
signed-by=/etc/apt/keyrings/docker.asc]\
https://download.docker.com/linux/ubuntu \
$(. /etc/os-release && echo "$VERSION_CODENAME") stable" | \
sudo tee /etc/apt/sources.list.d/docker.list > /dev/null

This command begins by calling the echo command to create a long string containing the Docker
repository information. Some of this information is retrieved from dpkg and other information is gotten
from a file. The output is then piped to the tee command (running under sudo) to save it to the apt
configuration directory in a file name docker.list. Simply redirecting the output of the echo command to
the file will not work in this case due to the permissions on the directory where docker.list is being
saved.

NOTE: The above command pipeline has been re-formatted to fit the page, the format on the above-
named web page is the same even though it looks different.

Page 19 of 23
INFO-3182- Operating systems - Linux

Step 3 – Update the package database again.

Update the package database again so that the packages in the Docker repository are included in it.
sudo apt-get update

At this point, the Docker repository is ready for use.

Step 4 – Install Docker Engine.

The next command installs Docker Engine from the Docker repository.
sudo apt-get install docker-ce docker-ce-cli containerd.io \
docker-buildx-plugin docker-compose-plugin

The docker-ce, docker-cli, and containerd.io packages are the core components of Docker Engine.
Docker-buildx-plugin package contains an optional advanced container creation feature which Docker
strongly recommends. The docker-compose-plugin is an optional container orchestration tool for use
with the Docker Swarm clustered container runtime environment. The Docker Swarm functionality is
installed as part of Docker Engine, although most organization prefer to use Kubernetes today.

Docker Engine is now installed and usable by the root user or via sudo. Some additional configuration is
needed for it to be usable by users without sudo privileges. Performing this additional configuration
creates some significant security concerns related to privilege escalation, so think carefully before doing
it.

The snap package management tool

The snap package management tool was introduced by Canonical a as way to simplify package
management, especially for optional packages. In many ways it has achieved this goal, but at the cost of
increased disk space utilization, every snap (package) includes all its dependencies. It is now an integral
part of Ubuntu and is also optionally available for other Linux distributions.

To list the snaps installed on a system use the command:


sudo snap list

Figure 22 shows the above command being used to display a list of the snaps installed on an Ubuntu
24.04 desktop system. The snaps listed are those that are installed during the operating system
installation process. Note that the Firefox web browser is installed as a snap, showing that more
common applications are starting to use snaps.

Page 20 of 23
INFO-3182- Operating systems - Linux

Figure 22 Screenshot showing the snaps installed on an Ubuntu 24.04 desktop system by default.

Information about a particular snap can be retrieved using the snap info command. Information on
all snaps can be obtained with this command, whether they are installed or not. For example, to display
information on the Firefox snap, use the command:
sudo snap info firefox

Figure 23 shows this command and its output.

Figure 23 Screenshot showing the snap info command providing information about the Firefox snap.

The snap find command is used to display information about snaps that are available for installation.
When this command is used without additional parameters, a selection of available snaps is listed with
brief descriptions as shown in Figure 24.

Page 21 of 23
INFO-3182- Operating systems - Linux

Figure 24 Screenshot showing the output of an execution of the snap find command without parameters. Note the message at
the beginning and end indicating that specific data can be found when more parameters are specified.

Figure 25 shows the snap find command retrieving information about the MicroK8S snap. MicroK8S
is a Kubernetes container orchestration system intended for use in development/test and small
production environments. This list gradually grows as software is updated. The command used in the
Figure is:
sudo snap find microk8s

Figure 25 Screenshot showing the snap find command listing details on the versions of the MicroK8S snap available for
installation.

The snap install command is used to install snaps. The information needed by the snap
install command varies with the snap being installed. It is often necessary to look at both the snap
find and snap info command output for a snap to find all the necessary information. For example, to
install the latest version of Multipass, the command is:
sudo snap install multipass

And to install MicroK8s, one way to install the latest version at the time of writing is:
sudo snap install microk8s --classic --channel=1.31

Page 22 of 23
INFO-3182- Operating systems - Linux

Figure 26 shows the command used to install MicroK8S and its output. The snap tool does not produce a
lot of output, instead it uses progress bars and short messages that all appear on the same line.

Figure 26 Screenshot showing MicroK8S being installed using the snap command.

When installing theMicroK8S snap, the --classic parameter tells snap to use a specific snap format and
the --channel parameter tells snap the version of the snap to install. Note that there are often multiple
ways to specify the channel value. Multipass does not use either of these parameters, it uses the default
snap format and channel.

Multipass is a simple single-host cloud environment that Canonical created for developers to use. It is
available for Linux systems, and Windows desktop systems with Hyper-V installed. Hardware
virtualization support is required.

Removing a snap is done using the snap remove command. For example, to remove the Microk8s
snap, use the command:
sudo snap remove microk8s

Figure 27 shows this command and its output. The snap remove command does not ask for
confirmation, be careful.

Figure 27 Screenshot of the snap remove command after uninstalling the MicroK8S snap.

Updating snaps is straightforward. Simply issue the command:


sudo snap refresh

This command checks for updated versions of the snaps installed on a system and installs any it fines. It
does not prompt the user to confirm the update.

Page 23 of 23

You might also like