The Linux distribution developers work hard to make sure package versions added to the repositories don't conflict with one another. Usually it's safest to upgrade or install a software package from the repository. Even if a newer version is available elsewhere, you may want to hold off installing it until that version is available in your Linux distribution's repository.
When you look at the file, you'll notice that it's full of helpful comments and warnings. The repository sources specified use the following structure:
deb (or deb-src) address distribution_name package_type_list
The deb
or deb‐src
value indicates the software package type. The deb
value indicates it is a source of compiled programs, whereas the deb‐src
value indicates it is a source of source code.
The address entry is the software repository's web address. The distribution_name entry is the name of this particular software repository's distribution's version. In the example, the distribution name is focal
. This does not necessarily mean that the distribution you are running is Ubuntu's Focal Fossa; it just means the Linux distribution is using the Ubuntu Focal Fossa software repositories. For example, in Linux Mint's sources.list
file, you will see a mix of Linux Mint and Ubuntu software repositories.
Finally, the package_type_list entry may be more than one word and indicates what type of packages the repository has in it. For example, you may see values such as main
, restricted
, universe
, or partner
.
When you need to add a software repository to your sources file, you can try to wing it yourself, but that more than likely will cause problems. Often, software repository sites or various package developer sites will have an exact line of text that you can copy from their website and paste into your sources.list
file. It's best to choose the safer route and just copy and paste.
The front‐end interface, apt
, provides intelligent command‐line options for working with the Debian‐based dpkg
utility.
Canonical, the creators of the Ubuntu Linux distribution, has developed an application container format called snap . The snap packaging system bundles all the files required 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: colin.king@canonical.com 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).
Real World Scenario
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.
Читать дальше