RPM Package Manager
* rpm -(RedHat Package Manager) provide package management
* RPM package can be installed on - RedHat, Centos, Fedora, Suse & Mint
* DEB package can be installed on - Ubuntu, Boss, Debien, kalilinux.
* .tar & .bin is for the both types of OS.
* Package explaination.
Ex : RealPlayer11.1.x86.rpm
1. RealPlayer > Package name.
2. 11 > Version
3. .1 > Update
4. x86 > Architecher.
5. .rpm > extention.
the 5 major task performed by rpm are -
1. Query
2. Verify
3. Installation
4. Upgrade
5. Uninstalation
I. QUERY
*Query : - Means consult the local rpm database to determine the package is installed os well as Query packages that have been downloaded locally or on local media i.e cdrom or dvd.
1. rpm -qa (dumps all installed packages from rpm database)
option 'a' will display installed packages on the system rpm mantioned database of all installed packages.
2. rpm -qa |wc -l ( Provide a count of installed number of packages)
3. rpm -qa |grep -i package name (To search a particular package and if you are unsure about exact naem of package the use option - this will tell if any package will install.)
4. rpm -ql packagename
5. rpm -qi packagename (This will give information about package as its recorded in the local rpm database. Each package is signed by Redhat. Evry package is having
licens, key ID , Size and package, url etc. RPM verify package automatically using GPG, MD5, SHA1 SUMS.)
6. rpm -qf path of the package (this will display package membership information for the nano file.)
ex - rpm -qf /usr/bin/which
rpm -qf /bin/grep
7. We can query a package before its install. we can down load a package and query directly
rpm -qi http://192.168.1.254/rh5/i386/server/dhcp (this will give information about the 'dhcp' package which resides on the http repository while the query of installed package is through local RPM database. The option give info like - Name, Version, Release date, Build date, Size, License, URL, Group,[to which group belong], Summary etc.)
-h (hash) >> This will print hash marks,
-v ( verbose)>> This will print package name.
8. rpm -qa --last (This will give the last installed package informations)
9. rpm -F package name (freshen / Repair the package)
II. VERIFY
:- Verify filesystem contents against installed package in RPM database.
1. #rpm -Va (verify allpackages on the system, returning info only, if there are discreption from the orignal installation.)
-V >> verify a rpm which is on local DB, or remote package on filesystem or remote filesystem such on http accessible location.
-a >> will display installed packages on system.
-f >> verify the package that the file belongs to.
2. #rpm -Va http
If no. O/P comes it means it pass the test
#echo $?
where '0' means no error
#rpm -Vf /usr/bin/nano
#seq 100000 > nano
This will temper the nano file, now run -
#rpm -Vf /usr/bin/nano
SM5 .... T /usr/bin/nano
> S (file size) means file size is changed what is in the database local RPM databse.
> M (Mode or permission) means mode or permission have changed, might be previous its having 755, now may be its have 455.
> 5 (MD5) means MD5 no longer checks out
>T (Modification time) means modification time is no longer the same what recorded in RPM database
> L (Sym link) means Symlink error.
> D (Device ) means device problem such as wrong device name, missing device,
> ? Means RPM is unable to read the file
> U discrepency with user owner
> G discrepency with Group owner
> C Configuration file
Note: If test fails, one of the following will be returned.
#ech $?
> 1 (This means file is having issue, So we can verify any file by prm if its changed.)
#rpm -ql nano
This will display contents of nano package or display all included files which also include any directory created by the package.
* The options for rpm divided into 3 different sections
1. Query options (with -q) :-
> c - Lists all config files
> d - Lists all documentation files.
> i - Display information about the package
> l - list the files in a package
2. Verify options (with -V) : -
> a - Queries all packages.
> f - Display information about the specified file.
3. Install/upgrade/Remove options :
> -e - Remove a given package.
> -i - Install a given package.
> -h - show hash progress when installing.
> -U - Upgrades a given package.
> -V - Provides Verbose output.
* To download nao package from web from command line , we can use wget commad: -
#wget http://www.nano-editor.rog/dist/v2.2/RPMS/nano.rpm
*Even if you need to grab a remote RPM package, we can still use wget utility.
#rpm -qc rsyslog (To find all config files)
#rpm -qd rsyslog (To find documentation files for a given package.)
#rpm -ql rsyslog (Provide a listing of a files that come with the package)
#rpm -qR rsyslog (Find out wheather a package has any dependencies)
* You don't want to go thorugh the trouble of uninstalling the package first only to reinstall it. You can use the "--replacepkgs" option :-
#rpm - ivh --replacepkgs rsyslog
* While quering use option '-q' if you know exact name of the package but if hou don't know exact name you get no result, so don't use only '-q' option while quering use '-qi' , '-ql', '-qa', or '-qf'
III. Install
:- It does not overwrites previous packages.
Note: use this metthode to install a new version of the kernel.
#rpm -ivh dhcp-3.0.5-7.el5.i386.rpm
#rpm -qi dhcp
#rpm -ql dhcp (Display files in the packages)
#rpm -qa |grep -i rsyslog
#echo $?
> If comes 1 then packge not installed.
#which rsyslog
#rpm -qf /usr/bin/rsyslog
IV. UPGRADE
:- It installs or overwrites existing packages.
#rpm -Uvh dhcp-3.0.5-7.el5.i386.rpm
*Freshen :- (update an existing packages)
Note: Freshen will not install package if it does not exits locally.
#rpm -Fvh (Fresh the current version of the package)
rpm -F >> only installs the new package if earlier version exists, the old versionwill removed.
V. REMOVAL
#rpm -ev rsyslog (remove the package)
Note: - Removal process considers dependencies and will complain if the removal will break or more package. To resolve this use "--nodeps" option.
#rpm -ev --nodeps rsyslog
Note : Bydefault the gpg-eky that use to sign the packages have not been imported to the rpm database, we need to import key, that's why we saw no-key when package installed.
* Import Redhat RPM-GPG-key to confirm package signatures: -
#rpm --import http://192.168.75.100/linux/Misc/RHEL6/RPM-GPG-KEY-redhat-release
> Now if we install any package it will not show no key in O/p.
> To check key -
#rpm -qa gpg-pubkey*
> This will show wheather key is installed or not.
#rpm -qi gpg-pubkey*
YUM CONFIGURATION
************************************
:- The yum command has access to repositories where tons of packages are kept and can install, pugrade or remove them automatically. Yum alos take care of resolving and installing any dependencies.
* Yum is an xml file. It resolve the dependancy. It is a front panal of RPM.
*YUM > Yellow-dog Updage Modifir.
* There is two type of YUM - yum-server & yum-client.
* Configuration file - /etc/yum.repos.d/
-----------------------------------------------------------------
Syntax : yum [options] command
> Options :
-c > Specifies the location of the config file.
-y > Indicates to always answer yes to prompts
-v > Provide verbose O/p
> Commands :
clean > removes cached data
erase > Removes a package from the system.
grouplist > Displays availbale package groups.
groupinstall > Installs the packages within a group.
info > Display information about a package.
install > Install a package on the system.
search > Enable you to search for a package.
update > Update a package.
* Now we will see that how to configure a software repository through "yum" and Install & Uninstall software.
> In the RedHat DVD there is a directory by the name of Package. The all rpm can be find in this directory given by RedHat. There is a file in 'Package' directory by the name of "RPM-G86-KEY-redhat-release". The all rpm in the pakcage directory is singned by RedHat and for the Signature Verification this file is being used.
> Yum provides us secure pakcage management feature, means the software will be installed only if there "key RPM-GPG-KEY" is match with the key file. This is a way to ensure your software before completely install in your system that this package/software has been not modifyed and its completely geniune before install the software.
Steps to create YUM.
1. first of all we will insert the DVD of RHEL in the system and mount in to the system on any mounting point.
#mount /dev/cdrw /mnt
#cd /mnt
#ls
2. Copy all the file/dir from mount point of DVD into /var/ftp/pub
#cp -avr * /var/ftp/pub
* Where - a - all
v - verbose
r -Recursive (Recursive, we use because all the directory & sub directory and all the content of these file/dir copy on target.)
3. creat a configuration file in "/etc/repos.d/" by any name but extention must be ".repo"
4. To Configue "YUM" the global configuration file of yum is > "/etc/yum.conf"
#cat /etc/yum.conf
* In this file '/etc/yum.conf' there is a main section on the top,
------------------------------------------------------------------------------
To see what particular versions are available to you via yum you can use the
"--showduplicates switch."
$ yum --showduplicates list httpd | expand
Loaded plugins: fastestmirror, langpacks, refresh-packagekit
Loading mirror speeds from cached hostfile
* fedora: mirror.steadfast.net
* rpmfusion-free: csc.mcs.sdsmt.edu
* rpmfusion-free-updates: csc.mcs.sdsmt.edu
* rpmfusion-nonfree: csc.mcs.sdsmt.edu
* rpmfusion-nonfree-updates: csc.mcs.sdsmt.edu
* updates: mirror.steadfast.net
Available Packages
httpd.x86_64 2.4.6-6.fc20 fedora
httpd.x86_64 2.4.10-1.fc20 updates
As far as installing a particular version? You can append the version info to the name of the package like so:
EX- $ sudo yum install-
For example in this case if I wanted to install the older version, 2.4.6-6 I'd do the following:
$ sudo yum install httpd-2.4.6-6
You can also include the release info when specifying a package. In this case since I'm dealing with Fedora 20 (F20) the release info would be "fc20", and the architecture info too.
$ sudo yum install httpd-2.4.6-6.fc20
$ sudo yum install httpd-2.4.6-6.fc20.x86_64
repoquery
If you're ever unsure that you're constructing the arguments right you can consult with repoquery too.
$ repoquery --show-duplicates httpd-2.4*
httpd-0:2.4.6-6.fc20.x86_64
httpd-0:2.4.10-1.fc20.x86_64
downloading & installing
You can also use one of the following options to download a particular RPM from the web, and then use yum to install it.
$ yum --downloadonly
-or-
$ yumdownloader
And then install it like so:
$ sudo yum localinstall
What if I want to download everything that package X requires?
$ yumdownloader --resolve
Example
$ yumdownloader --resolve vim-X11
Loaded plugins: langpacks, presto, refresh-packagekit
Adding en_US to language list
--> Running transaction check
---> Package vim-X11.x86_64 2:7.3.315-1.fc14 set to be reinstalled
--> Finished Dependency Resolution
vim-X11-7.3.315-1.fc14.x86_64.rpm | 1.1 MB 00:01
Notice it's doing a dependency check, and then downloading the missing pieces. See my answer that covers it in more details here: How to download a file from repo, and install it later w/o internet connection?.
Get yum to install a specific package version
*There are two ways to download a package without installing it.One is using the "downloadonly" plugin for yum, the other is using "yumdownloader" utility.
Downloadonly plugin for yum
-------------------------------------
1.Install the package including "downloadonly" plugin:
(RHEL5)
# yum install yum-downloadonly
(RHEL6)
# yum install yum-plugin-downloadonly
2.Run yum command with "--downloadonly" option as follows:
# yum install --downloadonly --downloaddir=
3.Confirm the RPM files are available in the specified download directory.
Note:
•Before using the plugin, check /etc/yum/pluginconf.d/downloadonly.conf to confirm that this plugin is "enabled=1"
•This is applicable for "yum install/yum update" and not for "yum groupinstall". Use "yum groupinfo" to identify packages within a specific group.
•If only the package name is specified, the latest available package is downloaded (such as sshd). Otherwise, you can specify the full package name and version (such as httpd-2.2.3-22.el5).
•If you do not use the --downloaddir option, files are saved by default in /var/cache/yum/ in rhel-{arch}-channel/packages
•If desired, you can download multiple packages on the same command.
•You still need to re-download the repodata if the repodata expires before you re-use the cache. By default it takes two hours to expire.
Yumdownloader
If downloading a installed package, "yumdownloader" is useful.
1.Install the yum-utils package:
# yum install yum-utils
2.Run the command followed by the desired package:
# yumdownloader
Note:
•The package is saved in the current working directly by default; use the --destdir option to specify an alternate location.
•Be sure to add --resolve if you need to download dependencies
* rpm -(RedHat Package Manager) provide package management
* RPM package can be installed on - RedHat, Centos, Fedora, Suse & Mint
* DEB package can be installed on - Ubuntu, Boss, Debien, kalilinux.
* .tar & .bin is for the both types of OS.
* Package explaination.
Ex : RealPlayer11.1.x86.rpm
1. RealPlayer > Package name.
2. 11 > Version
3. .1 > Update
4. x86 > Architecher.
5. .rpm > extention.
the 5 major task performed by rpm are -
1. Query
2. Verify
3. Installation
4. Upgrade
5. Uninstalation
I. QUERY
*Query : - Means consult the local rpm database to determine the package is installed os well as Query packages that have been downloaded locally or on local media i.e cdrom or dvd.
1. rpm -qa (dumps all installed packages from rpm database)
option 'a' will display installed packages on the system rpm mantioned database of all installed packages.
2. rpm -qa |wc -l ( Provide a count of installed number of packages)
3. rpm -qa |grep -i package name (To search a particular package and if you are unsure about exact naem of package the use option - this will tell if any package will install.)
4. rpm -ql packagename
5. rpm -qi packagename (This will give information about package as its recorded in the local rpm database. Each package is signed by Redhat. Evry package is having
licens, key ID , Size and package, url etc. RPM verify package automatically using GPG, MD5, SHA1 SUMS.)
6. rpm -qf path of the package (this will display package membership information for the nano file.)
ex - rpm -qf /usr/bin/which
rpm -qf /bin/grep
7. We can query a package before its install. we can down load a package and query directly
rpm -qi http://192.168.1.254/rh5/i386/server/dhcp (this will give information about the 'dhcp' package which resides on the http repository while the query of installed package is through local RPM database. The option give info like - Name, Version, Release date, Build date, Size, License, URL, Group,[to which group belong], Summary etc.)
-h (hash) >> This will print hash marks,
-v ( verbose)>> This will print package name.
8. rpm -qa --last (This will give the last installed package informations)
9. rpm -F package name (freshen / Repair the package)
II. VERIFY
:- Verify filesystem contents against installed package in RPM database.
1. #rpm -Va (verify allpackages on the system, returning info only, if there are discreption from the orignal installation.)
-V >> verify a rpm which is on local DB, or remote package on filesystem or remote filesystem such on http accessible location.
-a >> will display installed packages on system.
-f >> verify the package that the file belongs to.
2. #rpm -Va http
If no. O/P comes it means it pass the test
#echo $?
where '0' means no error
#rpm -Vf /usr/bin/nano
#seq 100000 > nano
This will temper the nano file, now run -
#rpm -Vf /usr/bin/nano
SM5 .... T /usr/bin/nano
> S (file size) means file size is changed what is in the database local RPM databse.
> M (Mode or permission) means mode or permission have changed, might be previous its having 755, now may be its have 455.
> 5 (MD5) means MD5 no longer checks out
>T (Modification time) means modification time is no longer the same what recorded in RPM database
> L (Sym link) means Symlink error.
> D (Device ) means device problem such as wrong device name, missing device,
> ? Means RPM is unable to read the file
> U discrepency with user owner
> G discrepency with Group owner
> C Configuration file
Note: If test fails, one of the following will be returned.
#ech $?
> 1 (This means file is having issue, So we can verify any file by prm if its changed.)
#rpm -ql nano
This will display contents of nano package or display all included files which also include any directory created by the package.
* The options for rpm divided into 3 different sections
1. Query options (with -q) :-
> c - Lists all config files
> d - Lists all documentation files.
> i - Display information about the package
> l - list the files in a package
2. Verify options (with -V) : -
> a - Queries all packages.
> f - Display information about the specified file.
3. Install/upgrade/Remove options :
> -e - Remove a given package.
> -i - Install a given package.
> -h - show hash progress when installing.
> -U - Upgrades a given package.
> -V - Provides Verbose output.
* To download nao package from web from command line , we can use wget commad: -
#wget http://www.nano-editor.rog/dist/v2.2/RPMS/nano.rpm
*Even if you need to grab a remote RPM package, we can still use wget utility.
#rpm -qc rsyslog (To find all config files)
#rpm -qd rsyslog (To find documentation files for a given package.)
#rpm -ql rsyslog (Provide a listing of a files that come with the package)
#rpm -qR rsyslog (Find out wheather a package has any dependencies)
* You don't want to go thorugh the trouble of uninstalling the package first only to reinstall it. You can use the "--replacepkgs" option :-
#rpm - ivh --replacepkgs rsyslog
* While quering use option '-q' if you know exact name of the package but if hou don't know exact name you get no result, so don't use only '-q' option while quering use '-qi' , '-ql', '-qa', or '-qf'
III. Install
:- It does not overwrites previous packages.
Note: use this metthode to install a new version of the kernel.
#rpm -ivh dhcp-3.0.5-7.el5.i386.rpm
#rpm -qi dhcp
#rpm -ql dhcp (Display files in the packages)
#rpm -qa |grep -i rsyslog
#echo $?
> If comes 1 then packge not installed.
#which rsyslog
#rpm -qf /usr/bin/rsyslog
IV. UPGRADE
:- It installs or overwrites existing packages.
#rpm -Uvh dhcp-3.0.5-7.el5.i386.rpm
*Freshen :- (update an existing packages)
Note: Freshen will not install package if it does not exits locally.
#rpm -Fvh (Fresh the current version of the package)
rpm -F >> only installs the new package if earlier version exists, the old versionwill removed.
V. REMOVAL
#rpm -ev rsyslog (remove the package)
Note: - Removal process considers dependencies and will complain if the removal will break or more package. To resolve this use "--nodeps" option.
#rpm -ev --nodeps rsyslog
Note : Bydefault the gpg-eky that use to sign the packages have not been imported to the rpm database, we need to import key, that's why we saw no-key when package installed.
* Import Redhat RPM-GPG-key to confirm package signatures: -
#rpm --import http://192.168.75.100/linux/Misc/RHEL6/RPM-GPG-KEY-redhat-release
> Now if we install any package it will not show no key in O/p.
> To check key -
#rpm -qa gpg-pubkey*
> This will show wheather key is installed or not.
#rpm -qi gpg-pubkey*
YUM CONFIGURATION
************************************
:- The yum command has access to repositories where tons of packages are kept and can install, pugrade or remove them automatically. Yum alos take care of resolving and installing any dependencies.
* Yum is an xml file. It resolve the dependancy. It is a front panal of RPM.
*YUM > Yellow-dog Updage Modifir.
* There is two type of YUM - yum-server & yum-client.
* Configuration file - /etc/yum.repos.d/
-----------------------------------------------------------------
Syntax : yum [options] command
> Options :
-c > Specifies the location of the config file.
-y > Indicates to always answer yes to prompts
-v > Provide verbose O/p
> Commands :
clean > removes cached data
erase > Removes a package from the system.
grouplist > Displays availbale package groups.
groupinstall > Installs the packages within a group.
info > Display information about a package.
install > Install a package on the system.
search > Enable you to search for a package.
update > Update a package.
* Now we will see that how to configure a software repository through "yum" and Install & Uninstall software.
> In the RedHat DVD there is a directory by the name of Package. The all rpm can be find in this directory given by RedHat. There is a file in 'Package' directory by the name of "RPM-G86-KEY-redhat-release". The all rpm in the pakcage directory is singned by RedHat and for the Signature Verification this file is being used.
> Yum provides us secure pakcage management feature, means the software will be installed only if there "key RPM-GPG-KEY" is match with the key file. This is a way to ensure your software before completely install in your system that this package/software has been not modifyed and its completely geniune before install the software.
Steps to create YUM.
1. first of all we will insert the DVD of RHEL in the system and mount in to the system on any mounting point.
#mount /dev/cdrw /mnt
#cd /mnt
#ls
2. Copy all the file/dir from mount point of DVD into /var/ftp/pub
#cp -avr * /var/ftp/pub
* Where - a - all
v - verbose
r -Recursive (Recursive, we use because all the directory & sub directory and all the content of these file/dir copy on target.)
3. creat a configuration file in "/etc/repos.d/" by any name but extention must be ".repo"
4. To Configue "YUM" the global configuration file of yum is > "/etc/yum.conf"
#cat /etc/yum.conf
* In this file '/etc/yum.conf' there is a main section on the top,
------------------------------------------------------------------------------
To see what particular versions are available to you via yum you can use the
"--showduplicates switch."
$ yum --showduplicates list httpd | expand
Loaded plugins: fastestmirror, langpacks, refresh-packagekit
Loading mirror speeds from cached hostfile
* fedora: mirror.steadfast.net
* rpmfusion-free: csc.mcs.sdsmt.edu
* rpmfusion-free-updates: csc.mcs.sdsmt.edu
* rpmfusion-nonfree: csc.mcs.sdsmt.edu
* rpmfusion-nonfree-updates: csc.mcs.sdsmt.edu
* updates: mirror.steadfast.net
Available Packages
httpd.x86_64 2.4.6-6.fc20 fedora
httpd.x86_64 2.4.10-1.fc20 updates
As far as installing a particular version? You can append the version info to the name of the package like so:
EX- $ sudo yum install
For example in this case if I wanted to install the older version, 2.4.6-6 I'd do the following:
$ sudo yum install httpd-2.4.6-6
You can also include the release info when specifying a package. In this case since I'm dealing with Fedora 20 (F20) the release info would be "fc20", and the architecture info too.
$ sudo yum install httpd-2.4.6-6.fc20
$ sudo yum install httpd-2.4.6-6.fc20.x86_64
repoquery
If you're ever unsure that you're constructing the arguments right you can consult with repoquery too.
$ repoquery --show-duplicates httpd-2.4*
httpd-0:2.4.6-6.fc20.x86_64
httpd-0:2.4.10-1.fc20.x86_64
downloading & installing
You can also use one of the following options to download a particular RPM from the web, and then use yum to install it.
$ yum --downloadonly
-or-
$ yumdownloader
And then install it like so:
$ sudo yum localinstall
What if I want to download everything that package X requires?
$ yumdownloader --resolve
Example
$ yumdownloader --resolve vim-X11
Loaded plugins: langpacks, presto, refresh-packagekit
Adding en_US to language list
--> Running transaction check
---> Package vim-X11.x86_64 2:7.3.315-1.fc14 set to be reinstalled
--> Finished Dependency Resolution
vim-X11-7.3.315-1.fc14.x86_64.rpm | 1.1 MB 00:01
Notice it's doing a dependency check, and then downloading the missing pieces. See my answer that covers it in more details here: How to download a file from repo, and install it later w/o internet connection?.
Get yum to install a specific package version
*There are two ways to download a package without installing it.One is using the "downloadonly" plugin for yum, the other is using "yumdownloader" utility.
Downloadonly plugin for yum
-------------------------------------
1.Install the package including "downloadonly" plugin:
(RHEL5)
# yum install yum-downloadonly
(RHEL6)
# yum install yum-plugin-downloadonly
2.Run yum command with "--downloadonly" option as follows:
# yum install --downloadonly --downloaddir=
3.Confirm the RPM files are available in the specified download directory.
Note:
•Before using the plugin, check /etc/yum/pluginconf.d/downloadonly.conf to confirm that this plugin is "enabled=1"
•This is applicable for "yum install/yum update" and not for "yum groupinstall". Use "yum groupinfo" to identify packages within a specific group.
•If only the package name is specified, the latest available package is downloaded (such as sshd). Otherwise, you can specify the full package name and version (such as httpd-2.2.3-22.el5).
•If you do not use the --downloaddir option, files are saved by default in /var/cache/yum/ in rhel-{arch}-channel/packages
•If desired, you can download multiple packages on the same command.
•You still need to re-download the repodata if the repodata expires before you re-use the cache. By default it takes two hours to expire.
Yumdownloader
If downloading a installed package, "yumdownloader" is useful.
1.Install the yum-utils package:
# yum install yum-utils
2.Run the command followed by the desired package:
# yumdownloader
Note:
•The package is saved in the current working directly by default; use the --destdir option to specify an alternate location.
•Be sure to add --resolve if you need to download dependencies
No comments:
Post a Comment