Mastering Linux System Administration. Richard Blum

Чтение книги онлайн.

Читать онлайн книгу Mastering Linux System Administration - Richard Blum страница 34

Mastering Linux System Administration - Richard Blum

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

dnf list installed Installed Packages NetworkManager.x86_64 1:1.22.8-5.el8_2 @BaseOS NetworkManager-config-server.noarch 1:1.22.8-5.el8_2 @BaseOS NetworkManager-libnm.x86_64 1:1.22.8-5.el8_2 @BaseOS NetworkManager-team.x86_64 1:1.22.8-5.el8_2 @BaseOS NetworkManager-tui.x86_64 1:1.22.8-5.el8_2 @BaseOS PackageKit.x86_64 1.1.12-4.el8 @AppStream PackageKit-glib.x86_64 1.1.12-4.el8 @AppStream abattis-cantarell-fonts.noarch 0.0.25-4.el8 @AppStream acl.x86_64 2.2.53-1.el8 @BaseOS adcli.x86_64 0.8.2-5.el8 @BaseOS at.x86_64 3.1.20-11.el8 @BaseOS attr.x86_64 2.4.48-3.el8 @BaseOS audit.x86_64 3.0-0.17.20191104git1c2f876.el8 @BaseOS audit-libs.x86_64 3.0-0.17.20191104git1c2f876.el8 @BaseOS … $

      There will be lots of packages installed on your server; it usually helps to redirect the output to the more or less command to look at the list in a controlled manner. You can also redirect the output to a text file for viewing in a text editor.

      dnf list installed > installed.txt

      The format of the listing is a little different from the format of the original package names, but you can probably pick out the different components. The package name and architecture are listed first, followed by the version and release. The third column shows what repository category the package came from.

      You can also look for a single installed package.

      $ dnf list installed bash Installed Packages bash.x86_64 4.4.19-10el8 @BaseOS $

      If the package isn't installed, dnf will tell you.

      $ dnf list installed zsh Error: No matching Packages to list $

      You can then check if the package is available in the software repository by using the list option with the software package name.

      $ dnf list zsh Last metadata expiration check: 0:00:18 ago on Sat 05 Dec 2020 10:33:03 AM EST. Available Packages zsh.x86_64 5.5.1-6.el8_1.2 BaseOS $

      Finally, if you need to find out what software package provides a particular file on your filesystem, use the provides option.

      dnf provides file_name

      Here's an example of trying to find what software provided the file /usr/bin/gzip :

      dnf checked two separate repositories: the local system (denoted by @System) and the default fedora repository (denoted by BaseOS). That allows you to easily check whether there's an update available for the file.

      Installing Software with dnf

      Installation of a software package using dnf is simple. All you need is the install option, followed by the package name.

      dnf install package_name

      This installs not only the software package specified, but also any package dependencies. The output will show you the package information, along with any dependent packages required to install, and prompt you to continue the installation.

      image Real World Scenario

      INSTALLING SOFTWARE USING DNF

      In this exercise, you'll install the Z shell software package using the dnf tool on your CentOS server.

      1 Log into your CentOS server as the root user account, using the password you created in Chapter 4, “Installing a Red Hat Server.”

      2 From the command prompt, enter the command dnf install zsh. You should see output that's similar to this:# dnf install zsh CentOS-8 - AppStream 2.4 kB/s | 4.3 kB 00:01 CentOS-8 - AppStream 883 kB/s | 6.2 MB 00:07 CentOS-8 - Base 154 B/s | 3.9 kB 00:25 CentOS-8 - Base 865 kB/s | 2.3 MB 00:02 CentOS-8 - Extras 2.3 kB/s | 1.5 kB 00:00 CentOS-8 - Extras 8.3 kB/s | 8.1 kB 00:00 Dependencies resolved. ============================================================================= Package Architecture Version Repository Size ============================================================================= Installing: zsh x86_64 5.5.1-6.el8_1.2 BaseOS 2.9 M Transaction Summary ============================================================================= Install 1 Package Total download size: 2.9 M Installed size: 7.2 M Is this ok [y/N]: y Downloading Packages: zsh-5.5.1-6.el8_1.2.x86_64.rpm 392 kB/s | 2.9 MB 00:07 ------------------------------------------------------------------------------ Total 362 kB/s | 2.9 MB 00:08 Running transaction check Transaction check succeeded. Running transaction test Transaction test succeeded. Running transaction Preparing : 1/1 Installing : zsh-5.5.1-6.el8_1.2.x86_64 1/1 Running scriptlet: zsh-5.5.1-6.el8_1.2.x86_64 1/1 Verifying : zsh-5.5.1-6.el8_1.2.x86_64 1/1 Installed products updated. Installed: zsh-5.5.1-6.el8_1.2.x86_64 Complete! #

      3 Test the installation by entering the command zsh. You will see a prompt from the new Z shell. If you receive an error message, something went wrong.

      4 Return to the Bash Shell by entering the command exit.

      5 Check whether the installation processed properly by entering the command dnf list installed zsh. You should see the package appear, as shown here: # dnf list installed zsh Installed Packages zsh.x86_64 5.5.1-6.el8_1.2 @BaseOS #

      ROOT PRIVILEGES

      To install new software packages, you must have root privileges, either by logging in as the root user account or by using the sudo command before the dnf command to gain root privileges for your user account.

      Upgrading Software with dnf

      In most Linux distributions, when you're working away in the graphical user interface (GUI), you get those nice little notification icons telling you a software upgrade to a new version is needed. Here at the command line, it takes a little more work.

      To see the list of all the available upgrades for your installed packages, type the following command:

      dnf list upgrades

      If you see that a particular software package needs upgrading, then type in the following command:

      dnf upgrade package_name

      If you'd like to upgrade all the packages listed in the upgrade list, just enter the following command:

      dnf upgrade

      One nice feature in dnf is the upgrade‐minimal command. It upgrades a package to the latest bug fix or security patch version instead of the latest and greatest version.

      Uninstalling Software with dnf

      The dnf tool also provides an easy way to uninstall software you no longer need by using the remove option.

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