查找与软件相关的文件
我有一个疑问。我正在做一个与 Linux 系统恢复概念相关的项目。我计划在失败的情况下执行应用程序明智的回滚。有没有办法找出系统中应用程序使用的所有文件?
好的。我会说清楚一点。例如,考虑 Firefox 应用程序。安装时,许多文件都会从 .deb 文件写入 /etc、/usr、/opt 等文件夹。在 Windows 中,所有文件都安装在程序文件下的一个文件夹中,而在 Linux 中则不然。那么有没有办法找出属于某个软件的文件呢?
谢谢。
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.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(4)
嗯,这可以涵盖几件事。
如果您的意思是,您的应用程序的安装提供了哪些文件?那么答案是,使用适当的包管理,以 rpm/deb/... 任何包的形式提供您的软件,卸载将处理其余的事情。
如果您的意思是,我们的应用程序正在引用哪些库?然后您可以使用 ldd 这将告诉您执行此应用程序时使用了哪些动态库。
如果您的意思是,我的应用程序正在积极使用哪些文件?然后看一下 lsof 的输出(lsof = list open files)(或者 ls /proc//fd/),这将显示应用程序打开的所有文件描述符(文件、套接字、管道、tty 等) )
或者您可以使用以上所有内容。
您无法跟踪的一件事(除非您自己记录)是您的应用程序在其生命周期内创建了哪些文件。
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.
确定与应用程序一起安装的所有文件取决于包管理器。我接触过的所有工具(apt、pacman)都具有这种功能。
要确定应用程序当前打开的所有文件,请使用 lsof。
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.
嗯,这取决于......
大多数Linux系统都有某种数据包管理软件,例如debian和ubuntu中的aptitude。在那里,您可以获得有关数据包所属内容的信息。您也许可以使用该信息。但这并不包括应用程序运行时创建的文件。
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.
如果您使用基于 RPM 的发行版,
它将重新打包旧文件并在事务中升级,以便您可以在出现问题时进行回滚。例如,要回滚到昨天的状态,
请参阅 本文了解其他示例。
If you are using an RPM based distro
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
See this article for other examples.