Linux how to download packages

Offline installation of packages

This article or section needs language, wiki syntax or style improvements. See Help:Style for reference.

From time to time you might end up with a copy of Arch Linux on an offline computer and want to install packages for it.

Contents

Install from file: pacman -U

The Pacman -U command installs packages from the provided paths, and is probably what you are looking for in casual use cases.

For one package:

For several packages:

Offline cache

You can stuff things into /var/lib/pacman/sync and /var/cache/pacman/pkg to make pacman think it has everything it needs to do searches, updates, and installs. This method is based on byte’s post from this thread.

Download the package databases on a computer with internet access and transfer them to your computer. If needed, change MIRROR to any mirror from the mirror status list.

Following steps will make sure you are working with up-to-date package lists, as if you ran pacman -Sy .

After transferring the *.db files to the offline PC, do the following:

To update a New Arch Linux base system after installation you may enter

Now open that textfile with an editor and delete all lines that are not URLs. Next, bring that list with you to a place where you have internet and either download the listed packages manually or run wget in an empty directory:

Take all the *.pkg.tar.gz files back home, put them in /var/cache/pacman/pkg and finally run

Local repository

Scenario: you have two Arch Linux machines, ‘Al’ (with internet connection) and ‘Bob’ (without internet connection), and you need to install some NVIDIA packages and their dependencies on ‘Bob’. In this example, the wanted packages are nvidia , nvidia-utils , and xf86-video-nouveau , but you want to use a dedicated directory instead of /var/cache/pacman/pkg/ and a dedicated repository called nvidia (instead of the usual core, extra etc. )

Generate a list of packages to download

This can be done on any Arch Linux machine which has up-to-date repository data bases (see above for links to database files); to create the list of links to the required packages, use:

The file nvidia.list will contain links to the listed packages and any others which they depend on which are not already installed on ‘Al’. Unless you have cleared your cache the packages you have installed will be in your cache location. You can check /etc/pacman.conf for the location. It is probably something like /var/cache/pacman/pkg/ .

Download/copy the packages and their dependencies

Obviously this requires an internet connection, so on ‘Al’ create a directory called /path/to/nvidia for the files and run:

Then copy the dependencies you have already installed from the cache. Either find them manually by browsing https://archlinux.org/packages/ or if the total size of all your packages is not too large just copy them all

Create a repository database just for these packages

This can be done on either ‘Al’ or ‘Bob’ using the repo-add command which comes with pacman (from version 3?); first, change to the /path/to/nvidia directory where the packages were downloaded, then create database file called nvidia.db.tar.gz :

Transfer the packages

Now all the packages have been downloaded, you do not need ‘Al’ anymore. Copy the contents of /path/to/nvidia to a the temporary NVIDIA packages cache directory on ‘Bob’. In this example, this folder is called /home/me/nvidia :

Next, pacman must be made aware of this new repository of packages. First copy your current pacman.conf :

Now in /etc/pacman.conf make sure that your SigLevel is set to Never as your repository will not provide signatures

and add the following lines at the bottom of pacman.conf :

Читайте также:  Казахская клавиатура для windows

You may also need to comment out the other repositories so stale defaults do not cause failed attempts to download from online Now, instruct pacman to synchronize with the dedicated NVIDIA repository we created:

This command finds the nvidia.db.tar.gz file in /home/me/nvidia and expands it to /var/lib/pacman/sync/nvidia to create a database of packages contained in the NVIDIA repository.

Install the packages

Finally install the packages:

Restoring online sources

Should Bob ever be put online we can restore access to the online sources by replacing /etc/pacman.conf with the previously created /etc/pacman.conf.old .

Compiled from the forums, with thanks to Heller_Barbe and byte

Источник

How to Download Packages Using Yum/DNF without Installing on Linux

Today, we’ll take a look at how we can use package managers to download only rpm packages(offline) without installing them with all dependencies on Linux.

Yum and Dnf package managers are used in RedHat distributions namely RedHat, CentOS and Fedora mostly for installation, reinstallation, update, upgrade and removal of rpm packages.

Note: Kindly note that yum-utils package has been deprecated in Centos & RHEL 7

There are two ways of downloading packages without installing them

1) yum-downloadonly utility
2) using yumdownloader
3) using dnf-download

Installing yum-downloadonly tool (CentOS & RHEL 6.8)

Let’s first install the downloadonly utility with the command below.

Downloading a package using yum-downloadonly

Now that we have downloaded the utility tool, let’s see how we can download a web server package (httpd)

Sample Output

NOTE: By default, the package is downloaded to /var/cache/yum directory. To specify an alternative path append the —downloaddir=/path/ flag e.g

The above command stores the samba package in the /opt directory.

Installing yumdownloader (CentOS & RHEL 7)

Install the EPEL repo first. Note that yum-utils is deprecated in Centos & RHEL 7

Downloading a package using yumdownloader

To download a package, run the command as shown below. The example shows the download of an openssh server.

NOTE:
The package is downloaded to the current working directory. You can specify an alternative directory by appending — destdir flag.

To download the package alongside the dependencies, append the —resolve flag.

Verifying the presence of dependencies

Downloading a package using dnf (Fedora 22 and later versions)

On Fedora 22 and later, yum is deprecated and in its place is the dnf package manager. To download a package using dnf, use the following syntax:

The example to download of samba package:

To download the dependencies, append the —resolve flag

Verify existence or download of dependencies

Check the presence of downloaded dependencies using the ls command.

Read Also:

Generally, the best and easiest way of installing packages is by using the yum install package-name 0r dnf install package-name commands. If you prefer downloading a package first and installing it later, ensure you download the dependencies as well using the —resolve flag and install all of them simultaneously to avoid getting dependencies errors.

Источник

How To Download a RPM Package Using yum Command Without Installing On Linux

I would like to only download the packages via yum and not install/update them. How do I download a RPM package using yum command under CentOS Enterprise Linux server 5.x or RHEL 5.x systems?

You need to install plugin called yum-downloadonly. This plugin adds a –downloadonly flag to yum so that yum will only download the packages and not install/update them. Following options supported by this plugin:

[a] –downloadonly : don’t update, just download a rpm file
[b] –downloaddir=/path/to/dir : specifies an alternate directory to store packages such as /tmp

  • No ads and tracking
  • In-depth guides for developers and sysadmins at Opensourceflare✨
  • Join my Patreon to support independent content creators and start reading latest guides:
    • How to set up Redis sentinel cluster on Ubuntu or Debian Linux
    • How To Set Up SSH Keys With YubiKey as two-factor authentication (U2F/FIDO2)
    • How to set up Mariadb Galera cluster on Ubuntu or Debian Linux
    • A podman tutorial for beginners – part I (run Linux containers without Docker and in daemonless mode)
    • How to protect Linux against rogue USB devices using USBGuard

Join Patreon

Please note following instructions are only tested on CentOS server but should work with RHN and RHEL without any problem.

How do I install yum-downloadonly plugin?

Type the following command to install plugin, enter:
# yum install yum-downloadonly
Sample output:

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:
# yum update httpd -y —downloadonly
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:
# yum update httpd -y —downloadonly —downloaddir=/opt
Sample output:

Читайте также:  How to customize windows

To see downloaded file, enter:
# ls -l /opt/*.rpm
Sample output:

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.
# yum -y install yum-utils.noarch
Now use the yumdownloader command which is a program for downloading RPMs from Yum repositories. Type the following command to download httpd rpm file:
# yumdownloader httpd
Sample outputs:

How Do I Extract Downloaded RPM File?

Type the command as follows:
# rpm2cpio httpd-2.2.3-31.el5_4.2.x86_64.rpm | cpio -idmv

🐧 Get the latest tutorials on Linux, Open Source & DevOps via

Category List of Unix and Linux commands
Documentation help • mandb • man • pinfo
Disk space analyzers df • duf • ncdu • pydf
File Management cat • cp • less • mkdir • more • tree
Firewall Alpine Awall • CentOS 8 • OpenSUSE • RHEL 8 • Ubuntu 16.04 • Ubuntu 18.04 • Ubuntu 20.04
Linux Desktop Apps Skype • Spotify • VLC 3
Modern utilities bat • exa
Network Utilities NetHogs • dig • host • ip • nmap
OpenVPN CentOS 7 • CentOS 8 • Debian 10 • Debian 8/9 • Ubuntu 18.04 • Ubuntu 20.04
Package Manager apk • apt
Processes Management bg • chroot • cron • disown • fg • glances • gtop • jobs • killall • kill • pidof • pstree • pwdx • time • vtop
Searching ag • grep • whereis • which
Shell builtins compgen • echo • printf
Text processing cut • rev
User Information groups • id • lastcomm • last • lid/libuser-lid • logname • members • users • whoami • who • w
WireGuard VPN Alpine • CentOS 8 • Debian 10 • Firewall • Ubuntu 20.04

Comments on this entry are closed.

Damn… it doesn’t work on CentOS 4.6. Is there way to do this on 4.x branch? Upgrading OS is not an option and yum install yum-downloadonly does not work…

I just did this today on CentOS 4.x… you can’t really do the same thing, but you can download all the needed updates to a directory, then install at your leisure with ‘rpm -Uvh *.rpm’. Here is the command I used:

yum check-update | egrep ‘(base|updates)’ | awk ‘< print $1 >’ | xargs -n 10 yumdownloader

Noop, the only way to get it by visiting centos http / ftp mirrors.

That is what I’m looking for. I have FC10 desktop at my work place, and another FC10 at my home. This way I could spare my home bandwidth …
Thank you!

Thanks vivek for this very cool and useful trick

I have some packages which are installed using yum command. Now, I installed downloadonly plug-in. How can I download these packages without uninstalling the installed packages?

This doesnt work if you already have the package.
Is there a way around this?

You can do
yum reinstall [package] –downloadonly
and it will stop during the reinstall and leave the package in a subdirectory of
/var/cache/yum
this worked better for me than using –installroot

reinstall asdf@asdf.tld Apr 19, 2011 @ 13:36

a quick followup, I wanted to download a copy of the package rpm that I already have installed, so I did a

yum reinstall –downloadonly –downloaddir=/home/bob package-1.3-7

but if you want to download a copy of a package older then you have then

yum downgrade –downloadonly –downloaddir=/home/bob package-1.3-1

Your tip saved me a huge headache just now 🙂

i want to install qmail in rhel5

use the –installroot option for yum to download already-installed packages.

It’ll download all the package’s dependencies to that location, but at least you’ll have the rpm you wanted.

so do:
yum install –downloadonly –downloaddir=/tmp/ –installroot=/tmp

*edit* posted with wrong e-mail

but this doesnt work on yum groupinstall it gives error

So, after it has been downloaded, I will try to take that package to another machine without internet connect and install from the downloaded package. What command would I run to install it from the downloaded package and not using internet connection?
If yum can’t do it, could anybody provide a another command or so..
Thanks

This works great – thanks for the tip !

Or just use:
yumdownloader [package]
to download file in current dir
yumdownloader is part of yum-utils package:
yum install yum-utils

great milek! thats just what i was looking for, thanks!

Thanks for the heads up. The faq has been updated.

Thank you so much for this guide, it helped me to download R-core and about 15 of its missing dependencies that I needed in a single shot for a later install.

thanks very much!

How do i download mediaplayer for Redhat 5 with windows moode?

And how I can download “yum-downloadonly-plugin” without install it .
This is the big lack I can’t stand on “Yum” distros! How I can do my scripts post-installation with a such lack?
This package is not heavy, so why isn’t not installed in standard?

Its great tool….I did the following steps to download CPP rpms

yum install yum-downloadonly

New to CENTOS & Yum, looking for the best way to download Splunk to our brand new server setup …. yum install is the command, but how do I get the Splunk download package to where I can install it?

We have RHN subsciption and successfully downloaded updates available to the specified destination directory.

I copied these downloaded files to RHEL5.5 machine.(which can not be kept under network due to security reasons)
Now, I need to do offline install/update of the downloaded packages on this machine.But failed to do this. Any suggestions ?
I used “yum localupdate *” command to perform this operation.

One strange fact is, yum localupdate command is resolving dependancies when connected to RHN. But, on a offline machine even though I have copied all dependant packages it is not resolving dependencies(For Ex., to update an already installed package it is unable to install a new package available in the same directory).

Any help is appreciated.

Then why cant you prepare a shellscript by including all the packages to be installed at once by giving the location too…
I mean we could try like rpm -Uvh some-thing.rpm
to install use just rpm -ivh some-thing.rpm
make this like a shell script and install them…

Jai Thanks for the reply.

I understand that “rpm -Uvh” can update installed packages but it can not resolve dependencies on its own. Ok, let me put my question this way,
why “yum localupdate * ” command on RHN connected machine is resolving dependencies on its own ? and why not the same command on an offline machine can not resolve all dependencies though all dependent packages are in the same local directory ?
My intention here is, do not resolve any dependency issues manually on an offline machine. localupdate by name it should behave similar on a RHN connected machine as well as on an offline machine.

Correct me if I am missing anything during packaging and extracting on an offline machine.
I downloaded all updates using ” yum update -y –downloadonly –downloaddir=/tmp ” and copied all these files to offline machine and ran “yum localupdate * ” command.

One more quick point, I am allowed to use/setup any yum repositories to achieve these automated updates of RPMs installed on a offline machine.

Yeah.. I figured it out myself. I followed the below sequense to install downloaded RPM updates on a offline machine.

First downloaded RPM updates on a RHN registered machine in the following way,
1) yum install yum-downloadonly // installed yum download only plugin
//Downloaded availbale RPM updates to the /root/RPM_Updates/downloads directory
2) yum update -y –downloadonly –downloaddir=/root/RPM_Updates/downloads
3) Packaged these downloads into a tar file and transferred them to the offline machine.

On a offline machine, I created a local repository of downloaded RPMs and installed them using yum update command. in the following way,
1) Untar’ed RPM updates to the “/root/RPM_Updates/downloads” directory
2) Created rhel_local.repo file with the following content and copied it into /etc/yum.repos.d directory,

[rhel-local]
name=rhel-local $releaseserver $basearch – rhel-local
baseurl=file:///root/RPM_Updates/downloads
enabled=1
gpgcheck=0

3) Installed createrepo rpm using Yum localinstall command.
yum localinstall createrepo-0.4.11-3.el5.noarch.rpm # Before executing this command, This RPM was downloaded from the RHN connected machine and copied to this offline machine.
4) createrepo /root/RPM_Updates/downloads # Created local repository with this command.
5) Yum update -y # Hurrah I succefully installed RPM updates now from the local repository with out any need of registering the machine with RHN. Ofcourse, I downloded these updated RPMs from the official RHN registered machine 🙂

Thanx Sandy!! Everything work exactly like the way you posted!

Источник

Читайте также:  Download windows media player visualizations
Оцените статью