开发者

Find the files related to a software

开发者 https://www.devze.com 2022-12-20 02:48 出处:网络
I have one doubt. I am doing a project related to system restore concept in Linux. There i am planning to开发者_JS百科 perform application wise rollback in case of failure. Is there any way to figure

I have one doubt. I am doing a project related to system restore concept in Linux. There i am planning to开发者_JS百科 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.


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.


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.


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.


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.

0

精彩评论

暂无评论...
验证码 换一张
取 消