Super User is a question and answer site for computer enthusiasts and power users. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

Let's say, I would like to figure out what pip install does, like what files are downloaded, where are they extracted, where is the temporary files, ...

Are there any suggested way to track the opened files by script under Linux?

share|improve this question

I think you're looking for Inotify. It tracks down changes to files and directories under a given path. And there are lot of options to make it work like you want. And also, this is not process dependent, so you get any changes made by any process or script.

You can also have a look at fschange, which uses inotify as backend.

And if you want a GUI tool, check out DaemonFS.

share|improve this answer
Using inotify, is there any way to determine which files were modified by which programs? – Anderson Green Dec 29 '12 at 1:51

You could use the "lsof" command to get a list of open files, for a process with a particular pid. Here's a useful introduction:

To get the process id of the command, you could do something like ps ax | grep pip. Then just pass that to lsof like so: lsof -p theprocessid

share|improve this answer
Then, my next question is how to get that process id asap cause the script is running so fast. Furthermore, because it's a script, some file accessing is done by other programs/scripts instead! – Drake Jan 28 '12 at 10:22
In that case, a better approach may be to use strace, combined with the -f option to "follow" child processes. You're going to get a lot more output though :) You can just run it like strace -f pip install. Or what Bibhas said :) – Penny Leach Jan 28 '12 at 11:03

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .