Package Management in Linux
Software is the basis of any operating system, allowing you to install and use different utilities.
In linux, software is distributed through the use of packages, which contain the actual software files.
Each distribution of Linux has its own package management system.
For Red Hat, there are two package management systems: RPM & YUM.
Working with RPM:
RPM stands for (Red Hat package Manager)
RPM is default package installation tool in Linux operating system.
By using RPM we can install, upgrade, Query, verify and remove the packages.
Before diving into package management, let’s look at the naming convention used by the system to describe packages.
Methods of Installation:
àTwo ways of Installations.
Standalone: In this type, we can install the packages through any removable media (or) through dump.
Installing and Removing packages:
Syn: #rpm <options> <pkg-name> --force --aid
Options: I ---> installs a given package
V ---> verbose output
H ---> Shows hash progress when installing
U ---> Upgrades a given package
E ---> Removes a given package
---force ---> Install the package with forcefully
---aid ---> Install the package along with dependencies
---nodeps ---> To erase an package without dependencies
Query options (with – q):
Syn: #rpm <options> <kg-name>
C ---> Lists all config files.
D ---> lists all documentation files.
I --->Displays information about the package.
L --->Lists the files in a package.
S --->status of the package.
Verify options (with-v):
-a ---> Queries all packages
F ---> displays information about the specified file.
---> For installing an application.
#rpm -ivh nano -2.2.6-1.x86_64.rpm
- For installing an application with forcefully
# rpm -ivh nano-2.2.6-1.x86_64.rpm --force
- If you want to upgrade this package (because you know that it is already installed), you can substitute the –I option for –U
#rpm - Uvh nano -2.2.6-1.x86_64.rpm
- For uninstalling a package
# rpm -e nano
- You can always reinstall the package at a later date if you keep the .rpm file on your system
#rpm - ivh -replace pkgs nano -2.26-1 .x86_64.rpm
Tip: A common situation to run into on the job is having to install a package that is already installed. You don’t have to go through the trouble of uninstalling the package first only to reinstall it. You can use the –replace pkg option alongside the regular install options to override an existing installation.
- Query the instal’ed system package for nano:
#rpm -qa / grep nano
- Query the information from the nano package:
#rpm -qi nano
- Suppose you are looking around on your new Red Hat installation and a file but aren’t sure what it does. You can use the –f option to query the package that the file belongs to, possibly giving you a better idea of what that file might be sued for.
- Find out where the /etc/syslog. Cong file came from by doing the following
#rpm -qf /etc/syslog.comf
- Use the -c option to find all config files
#rpm -qd rsyslog
- To find the documentation files for a given package.
#rpm -qd rsyslog
- To listing of all files that come with the package.
#rpm -q1 rsyslog
- To find out whether a package has any dependencies:
#rpm -qr rsyslog
Learn Linux by Tekslate - Fastest growing sector in the industry.
Explore Linux Training Online and course is aligned with industry needs & developed by industry veterans.
Tekslate will turn you into Linux Expert.
Network installation: In this level we can install the package from server through NFS (or) FTP services.
- First check the communication.
- For accessing the data shared from server
#rpm –ivh vsftpd* --force --aid
FTP Service: In this method to install the package the ftp server should have the dump of o/s under the ftp default sharable location
- First check the communication
# ping 192/168.0.254
- For accessing the data shared from the server.
#rpm -ivh ftp://192.168.0.254/pub/server/<pkg-name> --force --aid
Working with YUM:
- YUM stands for yellow dog update modifier.
- In this section, we look at the exact same tasks, except this time we use the more flexible yum utility.
- The yum command has access to repositories where tons of packages are kept and can install, upgrade, or remove them for you automatically.
- Yum also takes care of resolving and installing any dependencies for you, which the rpm command can’t do.
- Yum is an interactive tool which waits for the confirmation of a user.
- Yum is a default package management tool in Red Hat o/s.
- Using this tool we can install the required packages
- With dependencies.
Syn: Yum <options> <command> <package name>
c --> specifies the location of the config file
q --> specifies quit, no output
y --> to always answer yes to prompts.
V --> provides verbose output.
Clean --> Removes cached data.
Erase --> Removes a package from the system.
List --> Displays available packages
Install --> Install a package on the system.
Search --> Enables you to search for a package.
Update --> Updates a package.
Group list --> Displays available packages groups.
Group install --> Install a packages with in a group.
Group remove --> Removes a packages with in a group
YUM Server configuration:
- Mount the dvd
- Install RPM package (vsftpd)
#rpm – ivh vsftpd* --force –aid
- Copy the dump of o/s into the default sharable location ftp.
#cp –rvf /mnt/* /var/ftp/pub
*à means all the data under the mount point /mnt.
- Install the create repo package:
#rpm -ivh create repo* ---force --aid
- Create the new repository:
#create repo -g /var/ftp/pub/server/repo data/comps-rhel5-server-core.xml/ var/ftp/pub
Note: If any errors are showing then remove
#rm - fr /var/ftp/pub/repo data
- Open the YUM configuration file:
- name=yum server
- base url = ftp: //192.168.0.254/pub
- enable = 1
- gpgcheck = 0
- Restart the ftp service
# service vsftpd restart
# yum clean all
- To list out packages
- To install the package
# yum install postfix -Y
- You could also update the postfix package
#yum update postfix -y
- To remove the package
#yum remove postfix
Note: One great feature about yum is that instead of updating a single package, you can list all updates that need to be installed for the system.
#yum list updates
- From this list, you can choose to update packages individually or as a whole. If you cant to install all the updates
- To get a listing of all available “groups”,
- You can then install that “groups”:
#yum group install “Development Tools”
Note: Don’t forget that linux doesn’t handle whitespace the way that windows does. If you specify a group name, you need to enclose it in quotation marks(“ “ ).
Searching for packages:
- Find the postfix package to install:
#yum search postfix
- To find out more information about the postfix package:
#yum info postfix
---> To flush the cache, do the following
#yum clean all
Configuring Additional Repositories:
- Sometimes you might want to install a package that isn’t in the repositories that come preconfigured with Red Hat. If the package is available in someone else’s repository, you can add that person’s repository to your yum config file.
- You can either add your own custom repositories to the main config file /etc/yum.conf (or) create a .repo file in the /etc/yum. Repos.d directory which will be added automatically. Here is what a sample entry for a custom repository looks like:
Name = my custom yum repository.
Base url = ftp://126.96.36.199/opt/yum/myrepos
- One neat trick that you can do is to create a repository based on an ISO
- This trick can be useful in an environment whether there is no Internet access and you’d like to install packages from the Red Hat
Step 1): Create a folder for the temporary mount:
# mkdir /mnt/cd
Step 2): Mount the ISO image (or) cd:
# mount -o loop /dev/cdrom / mnt/cd
Note: ---> To create a ISO image.
#dd if =/dev/scdʘ of = /os/rhe/5.iso
To check it which device is mount
- Read the image file
#mount –o loop /OS/Rhel5.iso /DVD
Step 3): Create a repository in the temporary directory:
# cd / mnt
This creates an XML file of all the packages from the mounted CD.
Step 4): You also need to clean the current repository cache:
#yum clean all
Step 5) : Create a .repo file for your temporary repository:
Name = My Repository
Base url =file:///mnt/cd
Adding your custom packages:
- Just as you have already created two different types of custom repositories, you can add packages you have created to them as well.
Step 1): copy the file over to your private directory
#cp /usr/src/redhat/RPMS/x86_64/mysample – 1.0-0.x86_64.rpm
Step 2): Update the repository to recognize your new package:
#createrepo - update
- Now you should be able to search for your package in your private repository along with other software
Registering your system:
To register your system to the Red Hat Network, you must have an active sub scription with Red
Hat. You can register during the installation of your system or manually after the system has already been installed. Use the ‘rhn_register’ command to begin the registration process. After you finish, you can visit http://rhn.redhat.com to start managing your system(s) through the web. You need to make sure that the rhnsd daemon is running in order for it to be managed.
Step1): Set the daemon to boot on system start
# chkconfig rhnsd on
Step2): You should verify whether the service is currently running
#service rhnsd status
Step3): If it is, you are all set: otherwise, start the service manually:
# service rhnsd start
For indepth understanding of Linux click on