Mastering Linux System Administration. Richard Blum
Чтение книги онлайн.
Читать онлайн книгу Mastering Linux System Administration - Richard Blum страница 26
autoremove
command.
$ sudo apt autoremove Reading package lists… Done Building dependency tree Reading state information… Done The following packages will be REMOVED: zsh-common 0 upgraded, 0 newly installed, 1 to remove and 56 not upgraded. After this operation, 15.6 MB disk space will be freed. Do you want to continue? [Y/n] y (Reading database … 180928 files and directories currently installed.) Removing zsh-common (5.8-3ubuntu1) … Processing triggers for man-db (2.9.1-1) … $
The autoremove
command will check for all packages that are marked as dependencies and no longer required.
The apt Repositories
The default software repository locations for apt
are set up for you when you install your Linux distribution. The repository locations are stored in the file /etc/apt/sources.list
.
In most cases, you will never need to add or remove a software repository, so you won't need to touch this file. However, apt
will only pull software from these repositories. Also, when searching for software to install or update, apt
will only check these repositories. If you need to include some additional software repositories for your package management system, this is the place to do it.
SOFTWARE VERSIONS
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.
Using Snap Containers
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: [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