views:

65

answers:

4

Hello Friends, I have one doubt. I am doing a project related to system restore concept in Linux. There i am planning to perform application wise rollback in case of failure. Is there any way to figure out what are all the files used by an application in the system?

Ok. I will make it a little clear. For instance consider the firefox application. When it is installed many files are written from the .deb file to folders like /etc, /usr, /opt etc. In windows all the files are installed in one folder under program files while in linux its not. So is there any way to figure out the files that belong to a software?

Thanks.

+5  A: 

Well this can cover several things.

If you mean, which files are provided by the installation of your application ? Then the answer is, use decent package management, provide your software as an rpm/deb/... whatever package, and unstallation will take care of the rest.

If you mean, which libraries are being referenced by our application ? Then you can use ldd this will tell your which dynamic libraries are used when executing this application.

If you mean, which files is my application actively using ? Then take a look at the output of lsof (lsof = list open files) (or alternatively ls /proc//fd/), this will show all file descriptors open by your application (files, sockets, pipes, tty's, ...)

Or you could use all of the above.

One thing you can't track (unless you log this yourself) is which files have been created by your application during its lifetime.

amo-ej1
Your answer is more complete, upvoting.
profjim
Here it goes!! In linux the existing software do take backup of entire system as whole. But what i have planned is if some application say firefox which worked in some version say 2.4 after being updated to 2.5 did not work!! In that case i have planned to roll back the version to 2.4 by restoring the files which were backed up!! So to do this i need to find the files related to a software
DG
well this is exactly what package management in your distribution should do for you. This however will not cover files created at runtime (e.g. the firefox caches), since this link is not kept anywhere. Do keep in mind that software packages require libraries and the rolling back packages might imply rolling back libraries, which might imply problems in other application making use of the same libraries (confused yet ? ).
amo-ej1
@amo-ej1Thanks a lot buddy!! Yeah i got your point and i had thought of that too!! Well i am planning to study apt code for implementing this. I think that's the way to do that!! Is there any other suggestion??
DG
+1  A: 

To determine all the files installed along with the app depends on the package manager. All the ones I've dealt with (apt, pacman) have had this capability.

To determine all the files currently open by an application, use lsof.

profjim
A: 

Well, that depends ...

Most Linux system have some kind of packet management software, like aptitude in debian and ubuntu. There, you have information about what belongs to a packet. You might be able to use that information. That does not cover files created during runtime of apps though.

A: 

If you are using an RPM based distro

# rpm -Uvh --repackage pkg-1-1.i386.rpm

will repackage the old files and upgrade in a transaction so you can later rollback if something went wrong. To rollback to yesterday's state for example

# rpm -Uvh --rollback yesterday

See this article for other examples.

dtmilano