Every machine has yum and rpm installed, and these are the main methods of adding software to a machine.
This program is a higher-level interface to
rpm and repositories. RedHat systems must be registered with RHN to make full use of yum, because registration is the only way to access the offical RedHat repositories. Other repositories can be added by adding entries in /etc/yum.repos.d/, but this should be avoided unless some non-RedHat-supplied software is really needed.
It's written in Python, so be careful when updating python.
On RHEL 5, yum has replaced "up2date" for getting updates/packages/etc. that are requested on the RHN website.
yum search string1 [string2] […]
- Search for packages whose name or description match the given string(s)
yum install package1 [package2] […]
- Is used to install the latest version of a package or group of packages while ensuring that all dependencies are satisfied. If no package matches the given package name(s), they are assumed to be a shell glob and any matches are then installed. Sometimes a specific version of package must be specified (e.g. 32-bit versus 64-bit, or if mutliple versions of the same program are installed for some insane reason), see Package Names.
yum update [package1] [package2] […]
- Update packages with same name rules as "install". If no packages are named, all installed packages will be updated. Sometimes that's a bad thing; always use "check-update" first.
- Implemented so you could know if your machine had any updates that needed to be applied without running it interactively. Returns exit value of 100 if there are packages available for an update. Also returns a list of the pkgs to be updated in list format. Returns 0 and no packages are available for update.
yum remove package1 [package2] […]
- Remove packages and all packages that depend on them.
Note that there is no way to simply "reinstall" a package when using yum. Instead, a remove-install combo may be necessary. However, this can be trouble, because could wipe out a lot of innocent packages. So, either use rpm for this (preferred) or make sure to copy the list of packages that yum reports will be removed and install the whole list again.
- List the groups of packages available for specific functionality.
yum groupinfol "group name" ["group name2"] […]
- show the items installed for a specific group.
yum groupinstall "group name" ["group name2"] […]
- Install groups of packages for specific functionality.
Useful information about GROUPS
These are sets of packages that are useful to install together. There is an issue though that the install does not always do what you expect on Centos 7. See this writeup.
In our environment we would want at minimum:
yum -y group install "Development Tools" "Scientific Support" --setopt=group_package_types=mandatory,default,optional
Note the optional in the package types!!
The result is NOT always what you want. It seems that the optional packages are not installed if the particular package group was installed before, or is part of an "environment", such as "Compute Node" for "Scientific Support". This *also* does not allow you to remove the group. The best work arounds:
- Install the system as "Minimal" to begin with, then add the groups you want.
- If you don't want to re-install. You can use
repoquery -g -l --grouppkgs=optional "Scientific Support"to list the packages, and then pipe that into yum.
A package can be referred to for install,update,list,remove etc. with any of the following:
Mostly used by us to install packages that aren't in a repository and to reinstall broken packages without messing with packages that depend on them.
rpm -i package_file1 [package_file2] […]
- Installs the listed packages. Note that these are pathnames and not package names as used for yum.
rpm -e --nodeps package_name1 [package_name2] […]
- Removes the named packages, without removing packages that depend on them. Note that these are package names and not pathnames like when installing. I'm pretty sure the names don't follow the same rules as for yum, so the whole package name might be necessary.
This is, for pre-RHEL5 systems, the only method of getting updates/packages/etc. that are requested on the RHN website.
- Runs the interactive, GUI version, so if you SSH'd in, make sure it was with X forwarding. Not the preferred method, just because the interactive aspect isn't usually needed.
- Gets and installs the updates from RHN in "unattended" mode, with no GUI. Generally the best method, although some systems have some updates flagged to be skipped (things like new kernels).
See also: Tips and Trick for Yum
- Download but not install an rpm
yum reinstall --downloadonly --downloaddir=/root package-name
- Extract a single file from rpm
rmp2cpio package.rpm | cpio --list rmp2cpio package.rpm | cpio -ivd ./path/filename