MeeGo 1.2 Harmattan Developer Documentation Develop for the Nokia N9

Using lsof

The lsof tool is a Unix-specific diagnostic tool that is preinstalled on the Harmattan device. Its name stands for 'list open files', which is its main function. It lists information about any files that are open due to the processes currently running on the system. Open files in the system include disk files, pipes, network sockets and devices opened by all processes. One use for this command is when a disk cannot be unmounted because (unspecified) files are in use. The listing of open files can be consulted (suitably filtered if necessary) to identify the process that is using the file.


source: lsof

binary: lsof

Using the tool

To show files used by the process with the PID of 2415, enter the following command:

 lsof +p 2415

To show files used by the process whose name starts with mdecorator, enter the following command:

# lsof -c mdecorator                                                
mdecorato 3816 user  cwd    DIR      179,3    20480      12 /home/user          
mdecorato 3816 user  rtd    DIR      179,2     4096       2 /                   
mdecorato 3816 user  txt    REG      179,2    24428   15551 /usr/bin/mdecorator 
mdecorato 3816 user  mem    REG      179,2   121644     389 /lib/

To list all opened internet sockets, enter the following command:

 lsof -i

To list processes that use the /usr/lib/ library, enter the following command:

 lsof /usr/lib/

For all the parameters, enter the man lsof command. In a simple case, grep can be used to filter the necessary data from parameterless lsof output.

Further information

For more information on the tool, see the following links: