Hack 95. lsof Command Examples

byRamesh

Lsof stands for ls open files, which will list all the open files in the system. The open files include network connection, devices and directories. The output of the lsof command will have the following columns:

The lsof command by itself without may return lot of records as output, which may not be very meaningful except to give you a rough idea about how many files are open in the system at any given point of view as shown below.

# lsof | wc -l
3093

View open files by a specific user

Use lsof –u option to display all the files opened by a specific user.

Can u give me a way through which i can call the lsof command in C and give a call to my c function through java……i know how to give a call through java but din’t know the code that i have to write in C function to execute the lsof command.