🌐 🇵🇱 Polski · 🇬🇧 EN
Software is the foundation of any operating system, allowing us to use additional tools and capabilities through installation. In Linux, software is available in the form of packages containing the actual program files. Software is managed via a package management system. In the RedHat environment, these are: RPM and Yum.
WORKING WITH RPM
Packages contain a directory structure with files that make up a given application. In RedHat, packages are marked with the .rpm extension and may have various designations. Before we deal with the package management system, let's get familiar with the nomenclature used for labeling software packages.
Package name: package_name-version-release.arch.rpm
For example, let's look at the naming of a package containing an SMTP server:
postfix-2.6.6-2.el6.x86_64.rpm
You can see the name "postfix", the version number 2.6.6, and the designation for 64-bit systems. The "-2" symbol after the version indicates the release, and the "el6" designation indicates the RHEL06 system release. This is quite important information for an administrator; before starting the installation, you can already see from the name which system it is intended for and what version it is.
INSTALLING AND REMOVING PACKAGES
The first available way to work with packages is RPM. This tool is used for individual actions with packages outside of a repository. This means that while with the yum tool we search for a package in a repository and then install it, with RPM we are usually dealing with an external ".rpm" package downloaded beforehand. For both RPM and YUM, the number of available options is huge, and the most frequently used ones are presented here. Other options are available via the --help menu.
rpm syntax: # rpm [options]
rpm options are divided into three different sections: installation / upgrade / removal, query, and verification:
Installation / Upgrade / Removal:
- -e Remove a package
- -i Install a package
- -h Display installation process time (hash progress)
- -U Upgrade a package
- -v Display messages during operations
Query options (with the -q option):
- -c List all configuration files
- -d List all documentation files
- -i Display information about the package
- -l List files contained in the package
Verification options:
- -a Check the entire package
- -f Display information about specific files
Step 1 - Downloading the "nano" program package
# wget http://www.nano-editor.org/dist/v2.2/RPMS/nano-2.2.6-1.x86_64.rpm
--2010-09-06 08:30:26-- http://www.nanoeditor.
org/dist/v2.2/RPMS/nano-2.2.6-
1.x86_64.rpm
Resolving www.nano-editor.org... 207.192.74.17
Connecting to www.nano-editor.org|207.192.74.17|:80... connected.
HTTP request sent, awaiting response... 200 OK
Length: 586766 (573K) [application/x-redhat-package-manager]
Saving to: `nano-2.2.6-1.x86_64.rpm’
100%[================================================================
=>]
586,766 1.75M/s in 0.3s
2010-09-06 08:30:27 (1.75 MB/s) - `nano-2.2.6-1.x86_64.rpm’ saved
[586766/586766]
Step 2 - Installing the downloaded package
# rpm -ivh nano-2.2.6-1.x86_64.rpm
Preparing...
########################################### [100%]
1:nano
########################################### [100%]
The switches used here are: (-i) install, (-v) verbose mode, (-h) show progress bar. If a given package depends on others, we will see appropriate error messages. Manual installation is behind us.
If we want to upgrade a package that is already installed on the system, we replace the (-i) switch in the command with (-U).
# rpm -Uvh nano-2.2.6-1.x86_64.rpm
Preparing... ########################################### [100%]
1:nano ########################################### [100%]
To upgrade the current package, there is no need to uninstall it first; you can use the command:
# rpm -ivh --replacepkgs nano-2.2.6-1.x86_64.rpm
If a package is no longer needed on the system, it can be removed:
# rpm -e nano
If necessary, you can reinstall the package if you have the .rpm file or need to download the package from the network again.
CHECKING AND VERIFYING PACKAGES
After installing packages, it would be good to check which version of the package is currently visible on the system and whether it installed correctly. We can, of course, check this using the "rpm" command.
Checking whether a package is installed on the system is done with the command:
# rpm -qa | grep nano
nano-1.3.12-1.1.el6.x86_64
The -q option informs the "rpm" command that a query will be sent, the -a option says that the query concerns all packages installed on the system, which are then filtered by the "grep" tool, displaying (or not) the given package.
Now let's install the new version from the network:
# rpm -ivh nano-2.2.6-1.x86_64.rpm
Preparing... ########################################### [100%]
1:nano ########################################### [100%]
and let's verify again:
# rpm -qa | grep nano
nano-2.2.6-1.el6.x86_64
Let's go back a step. What if your boss tells you to install a postfix package from site "xyz" that you've never heard of before? You can get more information about it this way:
# rpm -qi nano
Name : nano Relocations: (not relocatable)
Version : 2.2.6 Vendor: (none)
Release : 1 Build Date: Thu 05 Aug 2010
11:08:24 PM EDT
Install Date: Mon 06 Sep 2010 08:35:32 AM EDT Build Host: 012.redhat.com
Group : Applications/Editors Source RPM: nano-2.2.6-1.src.rpm
Size : 1554146 License: GPL
Signature : (none)
URL : http://www.nano-editor.org/
Summary : A small text editor
Description :
GNU nano is a small and friendly text editor.
Now we know the basics about the package, such as the current version, release date, size, and information from the creators. Now we know how to install, upgrade, and check available packages. We can learn a few commands to do more with packages.
While logged into your new RedHat installation, try to find a file without being sure if it even exists. You can use the "-f" switch to query a package about a specific file, but perhaps a better idea might be to ask the system which package uses a given file. Find the file /etc/rsyslog.conf:
# rpm -qf /etc/rsyslog.conf
rsyslog-4.6.2-2.el6.x86_64
This query will tell you that the file rsyslog.conf belongs to the package rsyslog-4.6.2-2. The opposite situation may occur where we know the package name and want to check which configuration files it contains. For this purpose, we use the "-c" switch.
# rpm -qc rsyslog
/etc/logrotate.d/syslog
/etc/rsyslog.conf
/etc/sysconfig/rsyslog
Besides the -c option, we also have the -d option available, which searches for documentation files for a given package
# rpm -qd rsyslog
/usr/share/doc/rsyslog-4.6.2/AUTHORS
/usr/share/doc/rsyslog-4.6.2/COPYING
/usr/share/doc/rsyslog-4.6.2/NEWS
/usr/share/doc/rsyslog-4.6.2/README
/usr/share/doc/rsyslog-4.6.2/bugs.html
/usr/share/doc/rsyslog-4.6.2/build_from_repo.html
/usr/share/doc/rsyslog-4.6.2/contributors.html
/usr/share/doc/rsyslog-4.6.2/debug.html
/usr/share/doc/rsyslog-4.6.2/dev_queue.html
/usr/share/doc/rsyslog-4.6.2/droppriv.html
/usr/share/doc/rsyslog-4.6.2/expression.html
/usr/share/doc/rsyslog-4.6.2/features.html
/usr/share/doc/rsyslog-4.6.2/syslog_parsing.html
/usr/share/doc/rsyslog-4.6.2/syslog_protocol.html
/usr/share/doc/rsyslog-4.6.2/tls_cert_ca.html
/usr/share/doc/rsyslog-4.6.2/tls_cert_client.html
/usr/share/doc/rsyslog-4.6.2/tls_cert_errmsgs.html
/usr/share/doc/rsyslog-4.6.2/tls_cert_machine.html
/usr/share/doc/rsyslog-4.6.2/tls_cert_scenario.html
/usr/share/doc/rsyslog-4.6.2/tls_cert_server.html
/usr/share/doc/rsyslog-4.6.2/tls_cert_summary.html
/usr/share/doc/rsyslog-4.6.2/tls_cert_udp_relay.html
/usr/share/doc/rsyslog-4.6.2/troubleshoot.html
/usr/share/doc/rsyslog-4.6.2/v3compatibility.html
/usr/share/doc/rsyslog-4.6.2/v4compatibility.html
/usr/share/doc/rsyslog-4.6.2/version_naming.html
/usr/share/man/man5/rsyslog.conf.5.gz
/usr/share/man/man8/rsyslogd.8.gz
[output truncated]
Close to the -c and -d options is also the -l option, which displays all files contained in the package.
# rpm -ql rsyslog
/etc/logrotate.d/syslog
/etc/rc.d/init.d/rsyslog
/etc/rsyslog.conf
/etc/sysconfig/rsyslog
/lib64/rsyslog
/lib64/rsyslog/imfile.so
/lib64/rsyslog/imklog.so
/lib64/rsyslog/immark.so
/lib64/rsyslog/imtcp.so
/lib64/rsyslog/imudp.so
/lib64/rsyslog/imuxsock.so
/lib64/rsyslog/lmnet.so
/lib64/rsyslog/lmnetstrms.so
/lib64/rsyslog/lmnsd_ptcp.so
/lib64/rsyslog/lmregexp.so
/lib64/rsyslog/lmstrmsrv.so
/lib64/rsyslog/lmtcpclt.so
/lib64/rsyslog/lmtcpsrv.so
/lib64/rsyslog/lmzlibw.so
/lib64/rsyslog/omtesting.so
/sbin/rsyslogd
/usr/share/doc/rsyslog-4.6.2
/usr/share/doc/rsyslog-4.6.2/AUTHORS
/usr/share/doc/rsyslog-4.6.2/COPYING
/usr/share/doc/rsyslog-4.6.2/NEWS
/usr/share/doc/rsyslog-4.6.2/README
/usr/share/doc/rsyslog-4.6.2/bugs.html
[output truncated]
Earlier, it was also mentioned that packages may have dependencies on other packages, and to check what dependencies a given package has, we use:
# rpm -qR rsyslog
/bin/bash
/bin/sh
/bin/sh
/bin/sh
/bin/sh
/sbin/chkconfig
/sbin/chkconfig
/sbin/service
/sbin/service
bash >= 2.0
config(rsyslog) = 4.6.2-2.el6
coreutils
libc.so.6()(64bit)
libc.so.6(GLIBC_2.2.5)(64bit)
libc.so.6(GLIBC_2.3)(64bit)
libc.so.6(GLIBC_2.3.4)(64bit)
libc.so.6(GLIBC_2.4)(64bit)
libdl.so.2()(64bit)
libdl.so.2(GLIBC_2.2.5)(64bit)
libgcc_s.so.1()(64bit)
libgcc_s.so.1(GCC_3.0)(64bit)
libgcc_s.so.1(GCC_3.3.1)(64bit)
libpthread.so.0()(64bit)
libpthread.so.0(GLIBC_2.2.5)(64bit)
libpthread.so.0(GLIBC_2.3.2)(64bit)
librt.so.1()(64bit)
librt.so.1(GLIBC_2.2.5)(64bit)
libz.so.1()(64bit)
logrotate >= 3.5.2
rpmlib(CompressedFileNames) <= 3.0.4-1
rpmlib(FileDigests) <= 4.6.0-1
rpmlib(PayloadFilesHavePrefix) <= 4.0-1
rtld(GNU_HASH)
rpmlib(PayloadIsXz) <= 5.2-1
Comments