Take the 2-minute tour ×
Unix & Linux Stack Exchange is a question and answer site for users of Linux, FreeBSD and other Un*x-like operating systems.. It's 100% free, no registration required.

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

Reference:

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

share|improve this question

migrated from askubuntu.com May 12 '12 at 21:40

This question came from our site for Ubuntu users and developers.

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

1 Answer 1

up vote 2 down vote accepted

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
share|improve this answer
    
This was very helpful! Can I do the same thing, but only retrieve directories, and ignore files? –  Not 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 May 12 '12 at 18:17

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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