Mastering Linux System Administration. Richard Blum

Читать онлайн.
Название Mastering Linux System Administration
Автор произведения Richard Blum
Жанр Зарубежная компьютерная литература
Серия
Издательство Зарубежная компьютерная литература
Год выпуска 0
isbn 9781119794462



Скачать книгу

      Managing Packages with apt

      $ apt --installed list Listing… accountsservice/focal-updates,focal-security,now 0.6.55-0ubuntu12~20.04.4 amd64 [installed,automatic] adduser/focal,now 3.118ubuntu2 all [installed,automatic] alsa-topology-conf/focal,now 1.2.2-1 all [installed,automatic] alsa-ucm-conf/focal-updates,now 1.2.2-1ubuntu0.4 all [installed,automatic] amd64-microcode/focal,now 3.20191218.1ubuntu1 amd64 [installed,automatic] apparmor/focal-updates,now 2.13.3-7ubuntu5.1 amd64 [installed,automatic] apport-symptoms/focal,now 0.23 all [installed,automatic] apport/focal-updates,focal-security,now 2.20.11-0ubuntu27.12 all [installed,automatic] … $

      As you can guess, the list of installed packages will be long, so we've abbreviated the output to show just a sample of what the output looks like. Next to the package name is additional information about the package, such as the version name, and whether the package is installed and flagged for automatic upgrades.

      If you already know the package name and want to quickly display detailed information about it, use the show command.

      apt show package_name

      Here's an example of displaying the details of the package zsh :

      The apt show command does not indicate that the package is installed on the system. It shows only detailed package information from the software repository. One detail you cannot get with apt is a listing of all the files associated with a particular software package. To get this list, you will need to go to the dpkg command itself.

      dpkg -L package_name

      Here's an example of using dpkg to list all the files installed as part of the apt‐utils package:

      $ dpkg -L apt-utils /. /usr /usr/bin /usr/bin/apt-extracttemplates /usr/bin/apt-ftparchive /usr/bin/apt-sortpkgs /usr/lib /usr/lib/apt /usr/lib/apt/planners /usr/lib/apt/planners/apt /usr/lib/apt/solvers /usr/lib/apt/solvers/apt … $

      You can also do the reverse—find what package a particular file belongs to, as shown here:

      dpkg --search absolute_file_name

      Note that you need to use an absolute file reference for this to work.

      $ dpkg --search /usr/bin/apt-ftparchive apt-utils: /usr/bin/apt-ftparchive $

      The output shows the apt‐ftparchive file was installed as part of the apt‐utils package.

      Installing Software Packages with apt

      Now that you know more about listing software package information on your system, this section walks you through a software package installation. First, you'll want to determine the package name to install. How do you find a particular software package? Use apt with the search command.

      The beauty of the search command is that you do not need to insert wildcards around package_name. Wildcards are implied. By default, the search command displays packages that contain the search term in either the package name or the package description, which can be misleading at times. If you want to limit the output to only package names, include the ‐‐names‐only option.

      $ apt --names-only search zsh Sorting… Done Full Text Search… Done fizsh/focal,focal 1.0.9-1 all Friendly Interactive ZSHell zsh/focal 5.8-3ubuntu1 amd64 shell with lots of features zsh-antigen/focal,focal 2.2.3-2 all manage your zsh plugins zsh-autosuggestions/focal,focal 0.6.4-1 all Fish-like fast/unobtrusive autosuggestions for zsh zsh-common/focal,focal 5.8-3ubuntu1 all architecture independent files for Zsh zsh-dev/focal 5.8-3ubuntu1 amd64 shell with lots of features (development files) zsh-doc/focal,focal 5.8-3ubuntu1 all zsh documentation - info/HTML format zsh-static/focal 5.8-3ubuntu1 amd64 shell with lots of features (static link) zsh-syntax-highlighting/focal,focal 0.6.0-3 all Fish shell like syntax highlighting for zsh zsh-theme-powerlevel9k/focal,focal 0.6.7-2 all powerlevel9k is a theme for zsh which uses powerline fonts zshdb/focal,focal 1.1.2-1 all debugger for Z-Shell scripts $

      Once you find the package you'd like to install, installing it using apt is as easy as this:

      Since installing new software requires root privileges, you must use the sudo command in Ubuntu. The output will show basic information about the package and ask if you want to proceed with the installation.

      image Real World Scenario

      INSTALLING SOFTWARE USING APT

      Using the apt command makes installing software in Ubuntu easy. In this exercise, you'll install the Z shell on your Ubuntu server.

      1 Log into your Linux system as the sysadmin account created in Chapter 2, “Installing an Ubuntu Server.”

      2 From the command prompt, enter the command sudo apt install zsh. The sudo command is required to allow your user to run the apt command with root user privileges. Enter your user password when prompted. You should see something similar to this output: [sudo] password for sysadmin: Reading package lists… Done Building dependency tree Reading state information… Done The following additional packages will be installed: zsh-common Suggested packages: zsh-doc The following NEW packages will be installed: zsh zsh-common 0 upgraded, 2 newly installed, 0 to remove and 56 not upgraded. Need to get 4,450 kB of archives. After this operation, 18.0 MB of additional disk space will be used. Do you want to continue? [Y/n] y Get:1 http://us.archive.ubuntu.com/ubuntu focal/main amd64 zsh-common all 5.8-3ubuntu1 [3,744 kB] Get:2 http://us.archive.ubuntu.com/ubuntu focal/main amd64 zsh amd64 5.8-3ubuntu1 [707 kB] Fetched 4,450 kB in 4s (1,039 kB/s) Selecting previously unselected package zsh-common. (Reading database … 179515 files and directories currently installed.) Preparing to unpack …/zsh-common_5.8-3ubuntu1_all.deb … Unpacking zsh-common (5.8-3ubuntu1) … Selecting previously unselected package zsh. Preparing to unpack …/zsh_5.8-3ubuntu1_amd64.deb … Unpacking zsh (5.8-3ubuntu1) … Setting up zsh-common (5.8-3ubuntu1) … Setting up zsh (5.8-3ubuntu1) … Processing triggers for man-db (2.9.1-1) … $

      3 Test the install by entering the command zsh. You will see a menu prompting if you want to customize your Z shell environment. Enter 0 to use the default configuration. You should then get the Z shell prompt. ubuntu-server%

      4 Return to your normal Bash Shell by typing the command exit.

      5 Check