I'm configuring software on Ubuntu for i2b2, and trying to find all of the relevant files on a CentOS image that I downloaded (path below) and am now running on Windows VMWare Player (free for download). I'd like to create a file of the Linux file hierarchy recursively, for both CentOS and Ubuntu, so I can find the relevant files for each program (ie: JBoss, Java, Apache, Axis, Spring Web Framework, Oracle, etc..) and compare configuration. I know how to do a similar thing in Windows by getting the output of all files.

Long story short, I just want a dump of all files in the Linux file system starting at the root folder, and save it to a file.

Here's the command in Windows to do this:

WINDOWS-COMMAND-PROMPT>dir /b /a /s >> files_on_windows.txt


http://www.i2b2.org > Software (menu) > VMWare Image

  • Request from @Gilles to migrate to Unix & Linux – fossfreedom May 12 '12 at 21:39

A rough equivalent to your Windows command would use the find command:

find / -xdev >files_on_linux.txt

I don't think it would be very useful for what you're doing. On Linux (both CentOS and Ubuntu), programs come in packages; if you want to have the same programs on Ubuntu and CentOS, then you should obtain a list of packages on the CentOS machine, and install the same packages on Ubuntu. On CentOS, you can list the installed packages with the following command (the sed step strips off version numbers, which are irrelevant here):

rpm -qa | sed 's/-[0-9]*//' | sort >centos_packages.txt

The bad news is that CentOS and Ubuntu use different package names, so you can't take this list and do the installation on Ubuntu. You can cut some of the work by ignoring any package called libsomething, as these will be pulled in automatically by the programs that need them. Some of the package names will match one-for-one; you can install them as follows:

apt-get install $(grep -v '^lib' centos_packages.txt)

You can use the following command to see what packages are not installed or have a different name — it shows the lines that are present in centos_packages.txt but not in the output of dpkg --get-selections, which lists the installed (or selected-for-installation) packages on Ubuntu:

dpkg --get-selections | sort | comm -31 - centos_packages.txt

Additionally, there may be programs installed under /usr/local or /opt that do not come from the packaging system. You should be able to copy the files directly. You can do it this way:

cd /
sudo tar cjf usr_local.tar.bz2 opt usr/local

Copy the usr_local.tgz file to the new Linux system and unpack it:

cd /
sudo tar xjf usr_local.tar.bz2
  • This was very helpful! Can I do the same thing, but only retrieve directories, and ignore files? – MacGyver May 12 '12 at 18:11
  • @MacGyver find / -xdev -type d lists only the directories. Something like ls /bin /sbin /usr/bin /usr/sbin might be more useful for your purpose though. – Gilles 'SO- stop being evil' May 12 '12 at 18:17

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.