Find out what files a program is accessing




















I have a program which I am trying to run, however when I run it; it just complains that it can't find a particular file. However I have no idea which folder it is trying to find this particular file in. I have a copy of the required file, I just need to know which folder to copy it too.

Is there any way to show in real time which files are being accessed or which files are trying and failing to be accessed? I first posted my answer at this askubuntu question , but removed it from there and posted it here, as it is more relevant.

There are several ways you can investigate what files and libraries processes have opened; the main tools are lsof , strace and ltrace. Sometimes it is necesary to run them with sudo , so the program has access to everything it needs to gain an accurate snapshot of what a program is calling.

Firefox currently has a pid of on my system, so you could also use lsof -p , but you would have had to look up the process id first with ps aux grep [f]irefox. More information on lsof is detailed in this useful IBM article.

The main difference is that ltrace usually only traces library calls although it can trace system calls with the -S option , while strace traces both library and other system calls. More information on tracing processes is available in this IBM article. Lsof is probably more useful for you if you want to examine an already running process but strace can also do this and monitor the calls in real time when given a process pid sudo is always used when one attaches to a process :.

Omit the -c option to view the calls in real time. The results from strace and ltrace may not be greatly useful to you, as they are difficult to decipher unless you know what you are looking for, but lsof should provide some basic useful information.

Easiest way to do this seems to be to run the program through strace and watch for stat64 calls which get file info or open calls which open files. Ubuntu Community Ask! Sign up to join this community. The best answers are voted up and rise to the top. Stack Overflow for Teams — Collaborate and share knowledge with a private group. Open Computer Management. If the User Account Control dialog box appears, confirm that the action it displays is what you want, and then click Yes.

To disconnect all users, on the Action menu, click Disconnect all users. Helpful tips. How do I fix a file that is open in another program? We use cookies to ensure that we give you the best experience on our website.

If you continue to use this site we will assume that you are happy with it. View this "Best Answer" in the replies below ». Popular Topics in General Windows. Which of the following retains the information it's storing when the system power is turned off? Submit ». Khardiss May 13, at UTC. Lineup May 13, at UTC. Edited May 13, at UTC.

This topic has been locked by an administrator and is no longer open for commenting. Read these next



0コメント

  • 1000 / 1000