You are on page 1of 8

RPM queries: Information about specific packages

rpm -q: List what version of the package is currently installed

[user@host ~]$ rpm -q yum

 rpm -qi: Get detailed information about the package

 rpm -ql: List the files installed by the package

[user@host ~]$ rpm -ql yum

rpm -qc: List just the configuration files installed by the package

[user@host ~]$ rpm -qc openssh-clients

rpm -qd: List just the documentation files installed by the package

[user@host ~]$ rpm -qd openssh-clients

rpm -q --scripts: List shell scripts that run before or after the package is installed or removed

[user@host ~]$ rpm -q --scripts openssh-server

rpm -q --changelog: list change information for the package

[user@host ~]$ rpm -q --changelog audit

Installing RPM Packages

The rpm command can also be used to install an RPM package that you have downloaded to
your local directory.

[root@host ~]# rpm -ivh wonderwidgets-1.0-4.x86_64.rpm

Installed packages can be queried directly with the rpm command. Add the -p option to
query a package file before installation.

Command Task
rpm -qa List all RPM packages currently installed
rpm -q NAME Display the version of NAME installed on the system
rpm -qi NAME Display detailed information about a package
rpm -ql NAME List all files included in a package
rpm -qc NAME List configuration files included in a package
Command Task
rpm -qd NAME List documentation files included in a package
rpm -q --changelog
Show a short summary of the reason for a new package release
NAME
Display the shell scripts run on package installation, upgrade, or
rpm -q --scripts NAME
removal

View information for the rhcsa-script-1.0.0-1.noarch.rpm package.

[student@servera ~]$ rpm -qpi rhcsa-script-1.0.0-1.noarch.rpm

List files in the rhcsa-script-1.0.0-1.noarch.rpm package.

[student@servera ~]$ rpm -q -p rhcsa-script-1.0.0-1.noarch.rpm -l

View the script that runs when the rhcsa-script-1.0.0-1.noarch.rpm package is installed or
uninstalled.

student@servera ~]$ rpm -q -p rhcsa-script-1.0.0-1.noarch.rpm --scripts

Extract the contents of the rhcsa-script-1.0.0-1.noarch.rpm package in the /home/student


directory.

Use the rpm2cpio and cpio -tv commands to list the files in the rhcsa-script-1.0.0-
1.noarch.rpm package.

[student@servera ~]$ rpm2cpio rhcsa-script-1.0.0-1.noarch.rpm | cpio -tv

Extract all files from the rhcsa-script-1.0.0-1.noarch.rpm package in the /home/student


directory. Use the rpm2cpio and cpio -idv commands to extract the files and create the
leading directories where needed in verbose mode.

[student@servera ~]$ rpm2cpio rhcsa-script-1.0.0-1.noarch.rpm | cpio -idv

Managing Software Packages with Yum


yum list displays installed and available packages.

[user@host ~]$ yum list 'http*'

yum search KEYWORD lists packages by keywords found in the name and summary fields
only.

To search for packages that have “web server” in their name, summary, and description
fields, use search all:

[user@host ~]$ yum search all 'web server'

yum info PACKAGENAME returns detailed information about a package, including the disk
space needed for installation.

To get information on the Apache HTTP Server:

[user@host ~]$ yum info httpd

yum provides PATHNAME displays packages that match the path name specified (which often
include wildcard characters).

To find packages that provide the /var/www/html directory, use:

[user@host ~]$ yum provides /var/www/html

yum install PACKAGENAME obtains and installs a software package, including any
dependencies.

[user@host ~]$ yum install httpd

yum update PACKAGENAME obtains and installs a newer version of the specified package, including
any dependencies

[user@host ~]$ sudo yum update


yum remove PACKAGENAME removes an installed software package, including any supported
packages.

[user@host ~]$ sudo yum remove httpd

Like yum list, the yum group list command shows the names of installed and available
groups.

[user@host ~]$ yum group list

yum group info displays information about a group. It includes a list of mandatory, default,
and optional package names.

[user@host ~]$ yum group info "RPM Development Tools"

yum group install installs a group that installs its mandatory and default packages and the
packages they depend on.

[user@host ~]$ sudo yum group install "RPM Development Tools"

yum history displays a summary of install and remove transactions.

[user@host ~]$ sudo yum history

The history undo option reverses a transaction.

[user@host ~]$ sudo yum history undo 5

yum search guile


yum info guile
yum install guile
yum remove guile
yum remove gc
yum group list
yum group info "RPM Development Tools"
yum group install "RPM Development Tools"
yum history
yum history info 6
yum history undo 5
Enabling Yum Software Repositories
yum repolist all

The yum-config-manager command can be used to enable or disable repositories. To enable


a repository, the command sets the enabled parameter to 1. For example, the following
command enables the rhel-8-server-debug-rpms repository:

[user@host ~]$ yum-config-manager --enable rhel-8-server-debug-rpms

Creating Yum Repositories

yum-config-manager --add-
repo="http://dl.fedoraproject.org/pub/epel/8/x86_64/"

The following command installs the Red Hat Enterprise Linux 8 EPEL repository package:

[user@host ~]$ rpm --import http://dl.fedoraproject.org/pub/epel/RPM-GPG-


KEY-EPEL-8
[user@host ~]$ yum install
http://dl.fedoraproject.org/pub/epel/8/x86_64/e/epel-release-8-2.noarch.rpm

Use yum-config-manager to add the custom packages repository.

[root@servera ~]# yum-config-manager \


--add-repo "http://content.example.com/rhel8.0/x86_64/rhcsa-practice/rht"

Examine the software repository file created by the previous command in the /etc/yum.repos.d
directory.

[root@servera ~]# vim \


/etc/yum.repos.d/content.example.com_rhel8.0_x86_64_rhcsa-practice_rht.repo

 Create the /etc/yum.repos.d/errata.repo file to enable the updates repository with


the following content:

[rht-updates]
name=rht updates
baseurl=http://content.example.com/rhel8.0/x86_64/rhcsa-practice/errata
enabled=1
gpgcheck=0

 Use the yum repolist all command to list all repositories on the system:

[root@servera ~]# yum repolist all


Disable the rht-updates software repository and install the rht-system package.

1. Use yum-config-manager --disable to disable the rht-updates repository.

[root@servera ~]# yum-config-manager --disable rht-updates

2. List, and then install, the rht-system package:


3. [root@servera ~]# yum list rht-system
4. Available Packages
5. rht-system.noarch 1.0.0-1 content.example.com_rhel8.0_x86_64_rhcsa-
practice_rht
[root@servera ~]# yum install rht-system

Verify that the rht-system package is installed, and note the version number of the package.

[root@servera ~]# yum list rht-system

 Use yum-config-manager --enable to enable the rht-updates repository.

[root@servera ~]# yum-config-manager --enable rht-updates

se the yum update command to update all software packages on servera.

[root@servera ~]# yum update

 Verify that the rht-system package is upgraded, and note the version number of the
package.

[root@servera ~]# yum list rht-system


Installed Packages
rht-system.noarch 1.0.0-2.el7 @rht-updates

Modules
[user@host ~]$ yum module list
user@host ~]$ yum module list perl
[user@host ~]$ sudo yum module install perl

To verify the status of the module stream and the installed profile:

[user@host ~]$ yum module list perl


To remove an installed module:

[user@host ~]$ sudo yum module remove perl

To disable the module stream:

[user@host ~]$ sudo yum module disable perl

sudo yum module reset postgresql

sudo yum module install postgresql:10

Use the yum module list --installed command to list installed modules and streams.

[root@servera ~]# yum module list --installed

yum module remove postgresql

On serverb configure a software repository to obtain updates. Name the repository as errata and
configure the repository in the /etc/yum.repos.d/errata.repo file. It should access
http://content.example.com/rhel8.0/x86_64/rhcsa-practice/errata. Do not check
GPG signatures.

 Create the file /etc/yum.repos.d/errata.repo with the following content:

[errata]
name=Red Hat Updates
baseurl=http://content.example.com/rhel8.0/x86_64/rhcsa-practice/errata
enabled=1
gpgcheck=0

On serverb, install new package xsane-gimp and the Apache HTTP Server module from the 2.4
stream and the common profile.

yum list xsane-gimp

yum install xsane-gimp

yum module list

yum module install httpd:2.4/common


For security reasons, serverb should not be able to send anything to print. Achieve this by
removing the cups package. Exit from the root account.

yum list cups

yum remove cups.x86_64

The start script downloads the rhcsa-script-1.0.0-1.noarch.rpm package in the


/home/student directory on serverb.

Confirm that the package rhcsa-script-1.0.0-1.noarch.rpm is available on serverb. Install the


package. You will need to gain superuser privileges to install the package. Verify that the
package is installed. Exit from serverb.

1. Use the rpm command to confirm that the rhcsa-script-1.0.0-1.noarch.rpm package is


available on serverb by viewing the package information.

[student@serverb ~]$ rpm -q -p rhcsa-script-1.0.0-1.noarch.rpm -i

Use the sudo yum localinstall command to install the rhcsa-script-1.0.0-1.noarch.rpm


package. The password is student.

[student@serverb ~]$ sudo yum localinstall rhcsa-script-1.0.0-1.noarch.rpm

Use the rpm command to verify that the package is installed.

[student@serverb ~]$ rpm -q rhcsa-script

You might also like