for an application into a single snap distribution file. The difference between a snap package and a dpkg
package is that snap packages don't have any dependencies—all of the files needed to run an application are in the package installation. This can create duplication of files that could be shared with other applications, but it also resolves any issues that could occur from conflicting library files installed by multiple packages.
The snapd
application manages the snap packages installed on the system and runs in the background. You use the snap
command‐line tool to query the snap database to display installed snap packages, as well as to install, upgrade, and remove snap packages.
To check whether snap is running on your system, use the snap version
command.
$ snap version snap 2.47.1+20.04 snapd 2.47.1+20.04 series 16 ubuntu 20.04 kernel 5.4.0-53-generic $
If snap is running, you can see a list of the currently installed snap applications by using the snap list
command.
$ snap list Name Version Rev Tracking Publisher Notes core18 20200929 1932 latest/stable canonical* base lxd 4.0.4 18150 4.0/stable/… canonical* - snapd 2.47.1 9721 latest/stable canonical* snapd $
To search the snap repository for new applications, use the snap find
command.
$ snap find stress-ng Name Version Publisher Notes Summary stress-ng V0.11.24 cking-kernel-tools - A tool to load, stress test and benchmark a computer system $
To view more information about a snap application (snap for short), use the snap info
command.
$ snap info stress-ng name: stress-ng summary: A tool to load, stress test and benchmark a computer system publisher: Colin King (cking-kernel-tools) store-url: https://snapcraft.io/stress-ng contact: [email protected] license: GPL-2.0 description: | stress-ng can stress various subsystems of a computer. It can stress load CPU, cache, disk, memory, socket and pipe I/O, scheduling and much more. stress-ng is a re-write of the original stress tool by Amos Waterland but has many additional features such as specifying the number of bogo operations to run, execution metrics, a stress verification on memory and compute operations and considerably more stress mechanisms. snap-id: YMJsyW4vySPdys8BCA7jx8UiOVSVhUT6 channels: latest/stable: V0.11.24 2020-11-13 (5273) 3MB - latest/candidate: V0.11.24 2020-11-13 (5273) 3MB - latest/beta: V0.11.24 2020-11-13 (5273) 3MB - latest/edge: V0.11.24-44-20201121-7613-g2627a 2020-11-21 (5298) 3MB – $
To install a new snap, use the snap install
command as the root user (or with root privileges).
INSTALLING SOFTWARE SNAPS
The stress‐ng application allows you to stress test the CPU, memory, disk, and other features on your Linux system. Use the snap install
command to install the stress‐ng snap application package on your Linux system following these steps:
1 Log into your Ubuntu server using the sysadmin account you created in Chapter 2.
2 At the command line, enter the command sudo snap install stress‐ng. Enter your user password when prompted. You should see the following output: [sudo] password for sysadmin: stress-ng V0.11.24 from Colin King (cking-kernel-tools) installed $
3 At the command line, enter the command snap list to see if the stress‐ng snap package has been installed. You should see the following output: Name Version Rev Tracking Publisher Notes core18 20200929 1932 latest/stable canonical* base lxd 4.0.4 18150 4.0/stable/… canonical* - snapd 2.47.1 9721 latest/stable canonical* snapd stress-ng V0.11.24 5273 latest/stable cking-kernel-tools - $
When you install a snap package, the snapd
program mounts it as a drive. You can see the new snap mount by using the mount
command.
$ mount … /var/lib/snapd/snaps/stress-ng_5273.snap on /snap/stress-ng/5273 type squashfs (ro,nodev,relatime,x-gdu.hide) $
If you need to remove a snap, just use the snap remove
command.
$ sudo snap remove stress-ng stress-ng removed $
As the snap is removed, you'll see some messages about the progress of the removal. Instead of removing a snap, if you prefer, you can just disable it without removing it. Just use the snap disable
command. To reenable the snap, use the snap enable
command.
Installing from Source Code
Before package management systems and application containers, open source application developers had to distribute their software as source code and allow users to compile the applications on their own systems. Source code packages were commonly released as a tarball. Tarball packages bundle files into an archive file using the tar
command‐line command. Once the files are bundled into a tarball, it's common to use a compression utility to compress the file to easily distribute it.
Once you've obtained a software source‐code package tarball, there are a few steps you'll need to go through to install the software:
1 Unpack the files in the tarball using the tar command. The ‐xvf options expand the tarball specified on the command line. Optionally, if the tarball has been compressed, you'll need to include an option to uncompress the file. Use ‐J for .xz compressed files, or use ‐z for .gz compressed files.
2 Create the script for compiling the software on your system using the configure script included with the package. This detects what tools are installed on the system and what CPU features and capabilities are available. This creates a Makefile script to build the software.
3 Run the Makefile script to compile the source code using the make command.
4 Install the software using the make install command.
The software package developer determines the installation location and whether you need to have root privileges to run the application.
INSTALLING SOFTWARE FROM SOURCE CODE
If you develop or work with open source software source code much, there's a good chance you will still find software packed up as a tarball. This section walks you through the process of unpacking and installing a tarball software package.
For this example, the GNU software package hello
will be used. The hello
package is a simple program that produces a “Hello World!” output but demonstrates how GNU packages source code files for distribution.
1 Download the hello tarball package to your Ubuntu server. Go to the GNU software download website ftp.gnu.org/gnu/hello/. Click the link to download the current version of the package. The current filename is hello‐2.10.tar.gz.
2 Unpack the software tarball using the command tar ‐zxvf hello‐2.10‐tar.gz. This command will create a directory named hello‐2.10 and unpack all of the files into that directory.
3 Change to that directory by typing cd hello‐2.10. In this directory, you should see a README and an INSTALL file. It's important to read these files. In these files will be instructions you will need to finish the software's installation.
4 Run the configuration script by typing the command ./configure. You will see output messages as the script scans your system to check for the appropriate tools for building the software. If anything goes wrong, the configure step will display an error message explaining what's missing from your system.
5 Compile the application by typing make. You should see a lot of messages scroll by as the script compiles the individual pieces of the