[wplug] How to know open files

Bill Moran wmoran at potentialtech.com
Tue Jan 6 13:27:54 EST 2004


In addition to this ...

The BSDs come with a utility called fstat, which does a nice job of listing
all open files.  I've noticed that most Linux distros don't seem to have
an fstat, but it's highly possible that a package or rpm is available for
Linux

(fstat is one of the things I miss when I jump on a Linux box ...)

Patryk Laurent wrote:
> I'll be curious to find out what others say.  I have two suggestions.  
> 
> 1)  The first one is to check out "lsof" (lists open files.) 
> 
> 2)  Another possibility is to use /proc/*/fd/
> 
> For example, if I am running "less test" to view the file called "test",
> and less is running with process ID 3703, I can determine which files that
> process has open by doing:
> 
> $ cd /proc/3703/fd/
> $ ls -l
> lrwx------    1 patryk   patryk         64 Jan  6 14:14 0 -> /dev/pts/2
> lrwx------    1 patryk   patryk         64 Jan  6 14:14 1 -> /dev/pts/2
> lrwx------    1 patryk   patryk         64 Jan  6 14:14 2 -> /dev/pts/2
> lr-x------    1 patryk   patryk         64 Jan  6 14:14 3 -> /dev/tty
> lr-x------    1 patryk   patryk         64 Jan  6 14:14 4 -> /home/patryk/test
> 
> 
>   As you can see, it shows all file descriptors open by that process.

-- 
Bill Moran
Potential Technologies
http://www.potentialtech.com




More information about the wplug mailing list