Modern days sysadmins (System Administrator) has multiple jobs to perform daily or when required. One of the most important jobs is the installation, configuration, and management of software or app.
Requirements of software installation and configuration may come from users, apply updates to fix security problems, and supervise software and system up-gradation.
Generally, sysadmins perform all the following tasks:
- Automating mass installations of operating systems
- Maintaining custom OS configurations
- Keeping systems and applications patched and up to date
- Tracking software licenses
- Managing add-on software packages
To manage the installation of software on RHEL generally, two package databases are maintained
- RPM database
- YUM database
installing and managing software with rpm
When packages are installed through yum, the “Yum Database” is updated first, then the updated information is sync to the “RPM Database”. But when the “rpm command” is used to install packages, the update is written to the rpm database only, which is an important reason not to use the rpm command anymore to install
Metadata information for the installed package files is stored in the /var/lib/rpm directory.
Package management tools retrieve information about ownerships, permissions, timestamps, and file sizes from this directory location referred to as the package database.
The package database also contains information on package dependencies.
understanding rpm filenames
Generally RPM files delivered in a single file, normally with a filename in the format:
<name>-<version>-<release>.src.rpm for source packages, or
<name>-<version>-<release>.<architecture>.rpm for binaries.
For example, in the package filename autofs-5.0.7–40.el7.x86_64.rpm, the <name> is autofs, the <version> is 5.0.7, the <release> is 40.el7, and the <architecture> is x86_64. The associated source package would be named autofs-5.0.7–40.el7.x86_64.src.rpm
The extension “noarch.rpm” has been given to the RPMS that do not depend on a particular CPU architecture. For example, these RPMs may contain graphics and text for other programs to use. They may also contain shell scripts or programs written in other interpreted programming languages such as Python.
Each RPM package is a special archive made up of three components:
- Installed package File.
- Metadata Information about the package, such as the name/version/release/arch; a summary and description of the package; packages dependencies; licensing; a package changelog; and other details.
- Scripts that may run when this package is installed, updated, or removed, or which are triggered when other packages are installed, updated, or removed.
Enough of the theories, let’s explore the rpm command utility:
to list all software that is installed
$sudo rpm -qa
to install or update package
$sudo rpm -F OR -i OR -U OR -force OR -replacepkgs
- F = Upgrades an existing package.
- i = Installs a package.
- U = Upgrades an existing package or installs it if not already installed.
- h = Shows installation progress.
- force = Installs a package even if the same version already exists.
- replacepkgs = Overwrites existing packages.
to remove package
$sudo rpm -e [Package Name]
to get a description of the package
# rpm -qi nmap
to list all files that are in the package
# rpm -ql nmap
to list all document that are in the package
# rpm -qd nmap
to list all configuration file that are in the package
# rpm -qc nmap
to find the name of the rpm the ls command comes from
# rpm -qf /bin/ls
shows dependencies for a specific package
# rpm -qR nmap
to see which parts of the package have been changed since installation
# rpm -V
to verifies all installed packages and show which parts of the package have been changed since installation.
# rpm -Va
extracting files from rpm packages
# rpm2cpio wonderwidgets-1.0–4.x86_64.rpm I cpio -id “*txt “
It will extract the package in its current location
installing and managing software with yum
The yum command (yellowdog updater, modified) is a metapackage manager based on RPM and is the preferred tool for package management. It is very similar to APT package manager but cleaner and smarter.
This utility requires that the system has access to a software repository, local or remote. The main benefit of using um is that it automatically resolves dependencies by downloading and installing any additional required packages in order to successfully install the specified package.
specifying which repository to use
Create a file with a name that ends in .repo. In that file you need the following contents:
- [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
OptionExplanation[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 packagesgpgcheck=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 creating a repository file, the baseurl parameter is the most important because it tells your server where to find the files that are to be installed.
This will often be an HTTP or FTP URL, but it can be a file-based URL as well.
Yum Log FILE : /var/log/yum.log
creating your own repository
- Insert the installation disk in your virtual machine. This mounts it on the directory /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 .
- Type mkdir /repo to create a directory /repo that can be used as repository.
- 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 installation disk to the /repo directory.
- Type yum install -y createrepo to ensure that the createrepo RPM package is Installed.
- Type createrepo /repo . This generates the repository metadata, which allows you to use your own repository.
- 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:
- 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 packages that are offered through this repository.
using yum command
using yum to find software packages
To install packages with yum, you first need to know the exact name of the package. The yum search command can help you with that.
# yum search user
Because the yum search command looks in the package name and summary only, it often does not show what you need. You often need to look for packages containing a specific file.
The yum whatprovides or yum provides command will help.
# yum whatprovides */semanage
getting more information about packages
# yum info httpd
to list yum repo on system
# yum repolist
installing and removing software packages
# yum install nmap
# yum remove nmap
showing lists of packages
# yum list
It shows a list of all software packages that are available, including the repository they were installed from.
to show installed package
# yum list installed
to show installed package
# yum list packagename
# yum update (to update all)
# yum update httpd
working with yum package groups
# yum groups list
It will list group by name
to show hidden groups
# yum groups list hidden
to get information about packages available in a group,
# yum groups info
# yum groups info “Basic Web Server”
using yum history
# yum history list
undoing yum action
# yum history undo 14
to list kernel
# yum list kernel
enabling yum software repositories
Enable and disable repositories with yum-config-manager. This will change the enabled parameter in the /etc/yum.repos.d/redhat.repo file.
to enable repo
# yum-config-manager –enable rhel-7-public-beta-debug-rpms
Though yum install and yum update also allow you to download packages, you can use another tool called yumdownloader to download individual packages from an accessible repository.
# yumdownloader –v dhclient
This article is first published on loveopensrc.com