Saturday, July 21, 2012

LSOF - List of open file


This lists information about files opened by processes. It is great, especially when you are troubleshooting an issue and need more information about process or connection details. Linux treats most everything as a file. An open file may be a regular file, a directory, a block special file, a character special file, an executing text reference, a library, a stream or a network file (Internet socket, NFS file or UNIX domain socket.) A specific file or all the files in a file system may be selected by path. When a process or application interacts with these files it has to "open" them. Using this command you can dig into and see what your process is doing.
 
To show all the open TCP files - This will give you what service is running, who is running it, the process ID and the connections on all TCP ports:
 
#lsof -I TCP


Show open files or programs that is running on TCP port 80 

# lsof -i TCP:80 

COMMAND PID USER FD TYPE DEVICE SIZE NODE NAME 
httpd 21867 root 3u IPv4 98670393 TCP *:http (LISTEN) 
httpd 21891 apache 3u IPv4 98670393 TCP *:http (LISTEN) 
httpd 21892 apache 3u IPv4 98670393 TCP *:http (LISTEN) 
httpd 21893 apache 3u IPv4 98670393 TCP *:http (LISTEN) 
httpd 21894 apache 3u IPv4 98670393 TCP *:http (LISTEN) 
httpd 21895 apache 3u IPv4 98670393 TCP *:http (LISTEN) 
httpd 21896 apache 3u IPv4 98670393 TCP *:http (LISTEN) 
 


 

No comments:

Post a Comment

Install the Perl module

Unable to install a perl module and through below error: Looking for CPAN mirrors near you (please be patient) Can't locate Time/HiR...