Mastering Linux System Administration. Richard Blum

Читать онлайн книгу.

Mastering Linux System Administration - Richard Blum


Скачать книгу
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.

      Unlike the Ubuntu apt tool, dnf doesn't provide an option to remove the application files but keeps any configuration or data files. When you remove a package, everything associated with that package is removed.

      Handling Broken Dependencies

      Sometimes as multiple software packages get loaded, a software dependency for one package can get overwritten by the installation of another package. This is called a broken dependency.

      If this should happen on your system, first try the following command:

      dnf


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