1

I installed one package in my Linux machine and I want to install the same package on another Linux machine. Can I directly copy the installed directory from one computer to another computer? I mean cloning the installation directory.

Zanna
  • 70,465

1 Answers1

1

Considering software installed with APT/DPKG

On most Linux systems, including Ubuntu, there's no single installation directory for a package, although sometimes 3rd party software might have all its files in a single directory.

Instead, a package contains a set of files which are placed in multiple filesystem locations. Running whereis on a package shows the directories that contain its main parts:

$ whereis gimp
gimp: /usr/bin/gimp /usr/lib/gimp /etc/gimp /usr/share/gimp /usr/share/man/man1/gimp.1.gz

We can see gimp has files in at least /usr/bin, /usr/lib, /etc and /usr/share, all of which contain many files belonging to other packages.

You can use dpkg-query -L or the --listfiles option to read the file list of a package known to dpkg:

$ dpkg --listfiles g++
/.
/usr
/usr/bin
/usr/share
/usr/share/doc
/usr/share/man
/usr/share/man/man1
/usr/bin/g++
/usr/bin/x86_64-linux-gnu-g++
/usr/share/doc/g++
/usr/share/man/man1/g++.1.gz
/usr/share/man/man1/x86_64-linux-gnu-g++.1.gz

Note that the listing includes all the parent directories, even though the g++ package obviously did not provide them (to get only files you can do something like for i in $(dpkg --listfiles g++); do [[ -f "$i" ]] && echo "$i"; done, but some package installations do create directories).

The one for g++ is a very small file listing...

$ dpkg --listfiles gimp | wc -l
254
$ dpkg --listfiles xkb-data | wc -l
331
$ dpkg --listfiles linux-image-4.10.0-24-generic | wc -l
1312

Also consider that if you simply copied all the relevant files to all the relevant locations on another system, the package manager would know nothing about it, so the package would not be updated and its dependencies would not be installed, so it probably would not work at all for hard-to-debug reasons.

What this boils down to is that for software that is installable with APT, by far the easiest way to install it is with APT. If you want to save on downloading on each system, see How can I install software or packages without Internet (offline)?.

Some people consider this distributed style of installation to be... a bug. And many of them are doing something about it, for example creating distros that install packages discretely, or inventing cross-platform packaging solutions like snaps that allow discrete installation including all dependencies.

Zanna
  • 70,465