Doing It Again with Yum


--《Hands-on Guide to the Red Hat Exams RHCSA and RHCECert Guide and Lab Manual》

--《RHCE7》


man--yum


man--yum.conf


Syntax:

yum [options] command

Options:

参数 含义
-c Specifies the location of the config file
-q Specifies quiet, no output
-y Indicates to always answer yes to prompts
-v Provides verbose output

Commands:

命令 含义
clean Removes cached data
erase Removes a package from the system
grouplist Displays available package groups
groupinstall Installs the packages within a group
info Displays information about a package
install Installs a package on the system
search Enables you to search for a package
update Updates a package

Specifying Which Repository to Use

参数 含义
[label] The .repo file can contain different repositories, each section starting with a label that identifies the specific repository.
name= Use this to specify the name of the repository you want to use.
baseurl= Contains the URL that points to the specific repository location.

Key Options in .repo Files

Option Explanation
[label] The label used as an identifier in the repository file.
name= The name of the repository.
mirrorlist= Refers to a URL where information about mirror servers for this server can be obtained. Typically used for big online repositories only.
baseurl= The base URL where to go to find the RPM packages
gpgcheck= Set to 1 if a GPG integrity check needs to be performed on the packages. If set to 1, a gpgkey is required.
gpgkey= Specifies the location of the GPG key that is used to check package integrity.

When using a URL, two components are used. First, the URI identifies the protocol to be used and is in the format protocol://, such as http://, ftp:// or file://. Following the URI is the exact location on that URL. That can be the name of a web server or an FTP server, including the subdirectory where the files are found. If the URL is file based, the location on the file system starts with a / as well. Therefore, for a file system-based URL, there will be three slashes in the baseurl, such as baseurl:/// repo, which refers to the directory /repo on the local file system.

Repository Types and Their Support Status

Type Description
base This is the base repository that contains all essential Red Hat software. Its packages are fully supported.
updates A specific repository that contains updates only.
optional This repository contains packages that are provided for the convenience of Red Hat customers. The packages in this repository are open source and not supported by Red Hat.
supplementary This repository contains packages that are provided for the convenience of Red Hat customers. The packages in this repository are proprietary and not supported by Red Hat.
extras This repository contains packages that are provided for the convenience of Red Hat customers. Software in this repository comes from different sources and is not supported by Red Hat.

Exercise 11.1 Creating Your Own Repository

In this exercise, you learn how to create your own repository. To perform this exer- cise, you need to have access to the CentOS installation disk or ISO file.

  1. Insert the installation disk in your virtual machine. This mounts it on the direc- tory /run/media/user/CentOS 7 x86_64. Alternatively, you can manually mount the ISO on the /mnt directory, using mount -o loop /path/to/centos.iso /mnt .
  2. Type mkdir /repo to create a directory /repo that can be used as repository.
  3. If you want to create a complete repository, containing all the required files, type cp $MOUNTPATH/Packages/* repo . (Replace $MOUNTPATH with the name of the directory on which the installation disk is mounted.) If you do not need a complete repository, you can copy just a few files from the installa- tion disk to the /repo directory.
  4. Type yum install -y createrepo to ensure that the createrepo RPM package is installed.
  5. Type createrepo /repo . This generates the repository metadata, which allows you to use your own repository.
  6. Now that you have created your own repository, you might as well start using it. In the /etc/yum.repos.d directory, create a file with the name my.repo. Make sure this file has the following contents: [myrepo] name=myrepo baseurl=file:///repo
  7. Type yum repolist to verify the availability of the newly created repository. It should show the name of the myrepo repository, including the number of pack- ages that is offered through this repository (see Listing 11.3 ).

Exercise 11.3 Using yum for Package Management

In this exercise, you use yum for common package management tasks.

  1. Type yum repolist to show a list of the current repositories that your system is using.
  2. Type yum search xeyes . This will give no matching result.
  3. Type yum provides */xeyes . The command shows that the xorg-x11-apps- package contains this file.
  4. Install this package using yum install -y xorg-x11-apps . Depending on your current configuration, you might notice that quite a few dependencies have to be installed also.
  5. Type yum list xorg-x11-apps . You see that the package is listed as installed.
  6. Type yum history and notice the number of the last yum command you used.
  7. Type yum history undo (where is replaced with the number that you found in step 6). This undoes the last action, so it removes the package you just installed.
  8. Repeat the yum list xorg-x11-apps command. The package is now listed as available but not as installed.

results matching ""

    No results matching ""