Even very well designed operating system as Red Hat without software is worth not too much. In Red Hat and CentOS we use the same tools to get the programs and keep them up to date. Let’s have a look on RPM and YUM package manager.
Red Hat Package Manager (RPM) manages software in packages, a package includes software with instructions for adding, removing and upgrading files. RPM focuses on individual packages that sometimes require another software, libraries etc, then yum command is comming forward and resolve dependencies automatically. Dependency is a package that has to be installed alongside the rpm package to make sure all features will be working properly.
The Package contains binaries, installation scripts, configuration files and documentation, also instruction where and how to install those files. RPM database in /var/lib/rpm contains information about the version and location of given file in each RPM. The Repository is the place where the RPM packages are organized and stored.
Let’s have a look on the important rpm commands
rpm -i package.rpm – package installation
rpm -U package.rpm – package updgrading or installation if doesn’t exists
rpm -F package.rpm – package upgrading only (has to exist)
rpm -e package.rpm – removing package
rpm -qa or –query package.rpm – verifiying if package has been installed already
rpm -qa – lists all installed pckages
rpm -qc package.rpm – shows configuration files for given installed package
-vh (verbose) (hash marks) – help us monitoring of a package installation
–force – if we want to downgrade a package
rpm -i(UF)vh –force package.rpm
rpm -ivh package.rpm – standard installation of rpm package with verbose
rpm -U package.rpm – checking, if the rpm will overwrite any configuration file during installation process. RPM will make decision what to do and if makes decison about overwritting, shows the warning. The overwritten file will be saved in the same directory with .rpmsave extension
Dependencies and yum
Yum (yellow Dog Updater) resolves problems with manual installation of dependencies. Yum may be connected not only to internet but to local repository as well. There are 2 important files and directory regarding yum and its repositories configuration
/etc/yum.conf
/etc/yum
/etc/yum.repos.d
if you run yum-config-manager – you will get the full list of yum configuration
The most important from updating repositories point of view is folder /etc/yum.repos.d
Now, if we want to add our own repository , we have to add another file to /etc/yum.repos.d folder with extension .repo. Here is the CentOS-Base.repo file:
Let’s try to configure our own externall repository. In order to do that we have to create a file that contains :
[repositoryid]
name= the_name_of_the_repository
baseurl=url://path/to/the/repository (can be http://, ftp:// or file://)
optional:
enabled=0 repository active (by default)
gpgcheck=0 checking gpg keys (0=none)
now we have to save our repo file and then run commands
yum clean all – to to clean out database from previously accessed repositories
yum makecache – to update the local database from repository that we just created
There is a second way to install repository just from the file, take a look at the links below. We may install repositories from single file that will do everything for us and put a .repo file into /etc/yum.repos.d directory
yum install –nogpgcheck https://download1.rpmfusion.org/free/el/rpmfusion-free-release-7.noarch.rpm
yum install –nogpgcheck http://rpms.famillecollet.com/enterprise/remi-release-7.rpm
yum install –nogpgcheck http://repo.webtatic.com/yum/el7/webtatic-release.rpm
The 3rd way is by using wget or rpm command :
wget https://dl.fedoraproject.org/pub/epel/epel-release-latest-7.noarch.rpm
rpm -ivh https://dl.fedoraproject.org/pub/epel/epel-release-latest-7.noarch.rpm
the 4th way is just use yum command if we know the name of repository
yum install epel-release
new updated repos are being stored in /etc/yum.repos.d
Yum commands
yum list package -shows installed or available packages
yum repolist all – shows all configured repositories
yum info package – show info about given package
yum install package
yum update package
yum remove package
yum update – makes update of database of repositories
yum list updates – list of available updates
yum whatprovides “*part_of_name” – if we don’t know the full name of searching package
yumdownloader and yum-config-manager – contain settings regarding each repository and individual rpm packages.
yum-config-manager –add-repo=”http://192.156.123.1/pub” – adding repository automatically
yumdownloader package.rpm – download rpm with dependencies from repositiories instead of just install its
yum group – enables us installation of not only a single package but packages associated with its, let’s have a look on the example. I am going to install “Print server” group yum group info “Print Server”
as we see all packages would be installed if we just install print server without “group install“, but thanks to “group” install we may decide which packages we don’t want to install, we do that with “-x” switch
yum group install “Print Server” -x paps -x foomatic
if we want to add package that we missed or just didn’t install before, we use “+x”