If you ever wanted to download the rpm package instead of installing it with yum ! you can do that with ease, that is useful when you want to keep backup of some RPMs or want to see what’s inside RPM etc.
So how to download a RPM package using yum command under CentOS, Enterprise Linux server 5.x or RHEL 5.x systems (any yum supported) ?
First you need to install plugin called “yum-downloadonly”. After installing the plugin you can use –downloadonly flag to yum so that yum will only download the packages and will not install/update them. Following options supported by this plugin:
1 | [a] --downloadonly : don't update, just download a rpm file |
2 | [b] --downloaddir=/path/to/ dir : specifies an alternate directory to store packages such as /tmp |
Please note following instructions are only tested on CentOS server but should work with Fedora, RHN and RHEL without any problem.
To install yum-downloadonly plugin:-
Type the following command to install plugin, enter:
Sample output:
01 | Loading "fastestmirror" plugin |
02 | Loading "security" plugin |
03 | Loading mirror speeds from cached hostfile |
04 | * base: centos.mirrors.tds.net |
05 | * updates: mirror.myriadnetwork.com |
06 | * addons: mirrors.gigenet.com |
07 | * extras: holmes.umflint.edu |
08 | Setting up Install Process |
09 | Parsing package install arguments |
11 | --> Running transaction check |
12 | ---> Package yum-downloadonly.noarch 0:1.1.10-9.el5.centos set to be updated |
13 | --> Finished Dependency Resolution |
15 | ============================================================================= |
16 | Package Arch Version Repository Size |
17 | ============================================================================= |
19 | yum-downloadonly noarch 1.1.10-9.el5.centos base 9.0 k |
21 | ============================================================================= |
25 | Total download size: 9.0 k |
28 | (1/1): yum-downloadonly-1 100% |=========================| 9.0 kB 00:00 |
29 | Running rpm_check_debug |
30 | Running Transaction Test |
31 | Finished Transaction Test |
32 | Transaction Test Succeeded |
34 | Installing: yum-downloadonly |
35 | Installed: yum-downloadonly.noarch 0:1.1.10-9.el5.centos |
How do I download a RPM package only from RHN or CentOS mirror, without installing it?
Download httpd package but don’t install/update, enter:
By default package will by downloaded and stored in /var/cache/yum/ directory. But, you can specifies an alternate directory to store packages such as /opt, enter:
Sample output:
01 | yum install httpd -y --downloadonly |
02 | Loading "downloadonly" plugin |
03 | Loading "fastestmirror" plugin |
04 | Loading "security" plugin |
05 | Loading mirror speeds from cached hostfile |
06 | * base: centos.mirrors.mypsh.com |
07 | * updates: mirror.steadfast.net |
08 | * addons: mirrors.gigenet.com |
09 | * extras: holmes.umflint.edu |
10 | Setting up Install Process |
11 | Parsing package install arguments |
13 | --> Running transaction check |
14 | ---> Package httpd.i386 0:2.2.3-11.el5_1.centos.3 set to be updated |
15 | filelists.xml.gz 100% |=========================| 2.8 MB 00:03 |
16 | filelists.xml.gz 100% |=========================| 681 kB 00:11 |
17 | filelists.xml.gz 100% |=========================| 122 kB 00:00 |
18 | filelists.xml.gz 100% |=========================| 150 B 00:00 |
19 | --> Finished Dependency Resolution |
21 | ============================================================================= |
22 | Package Arch Version Repository Size |
23 | ============================================================================= |
25 | httpd i386 2.2.3-11.el5_1.centos.3 base 1.1 M |
27 | ============================================================================= |
31 | Total download size: 1.1 M |
33 | (1/1): httpd-2.2.3-11.el5 100% |=========================| 1.1 MB 00:01 |
34 | exiting because --downloadonly specified |
To see downloaded file, enter:
Sample output:
1 | -rw-r--r-- 1 root root 1116426 Jan 17 03:36 /opt/httpd-2.2.3-11.el5_1.centos.3.i386.rpm |
2 | -rw-r--r-- 1 root root 83452 Oct 2 2007 /opt/lighttpd-fastcgi-1.4.18-1.el5.rf.i386.rpm |
3 | -rw-r--r-- 1 root root 635045 Oct 20 2007 /opt/psad-2.1-1.i386.rpm |
Method # 2: yum-utils.noarch Package
yum-utils is a collection of utilities and examples for the yum package manager. It includes utilities by different authors that make yum easier and more powerful to use. These tools include: debuginfo-install, package-cleanup, repoclosure, repodiff, repo-graph, repomanage, repoquery, repo-rss, reposync, repotrack, verifytree, yum-builddep, yum-complete-transaction, yumdownloader, yum-debug-dump and yum-groups-manager.
Now use the yumdownloader command which is a program for downloading RPMs from Yum repositories. Type the following command to download httpd rpm file:
Sample outputs:
1 | Loaded plugins: rhnplugin |
2 | httpd-2.2.3-31.el5_4.2.x86_64.rpm | 1.2 MB 00:00 |
How Do I Extract Downloaded RPM File?
Type the command as follows: