Article:Listing open files and sockets on linux

If you are working in a unix system, sometime it is not obvious if a file is being opened by some other processes or not. Sometime this information is necessary.

You can get a list of all open files by using lsof command. Depending on your local configurations, you may need root privileges to run it.

lsof is much more useful if used together with grep. For example, if you want to see if someone is opening your secret file, you can do

% lsof | grep 'secret_file'

Furthermore, since in unix "everything is a file," you can even do:

% lsof | grep /dev/dsp

to see what process is locking your sound device.

or if a port is in use try netstat -nap


Most Recent

Most Popular

Most Active Categories




Back To Top Add New Article Printable Page

Unix

MediaWiki

This page has been accessed 4,025 times.

This page was last modified 01:14, 27 September 2005.