This Blog is to share our knowledge and expertise on Linux System Administration and VMware Administration

Monday, November 20, 2017

lsof command with example - Linvirtshell

The lsof is an excellent utility that can be used to identify process or user that is locking system resource such as file or network socket.

Basically, the /etc/services system files is usually used to map a numeric port number to a descriptive port name defined by user.

In the absence of any options, lsof lists all open files belonging to all active processes.

NAME

       lsof - list open files

To report all processes that are accessing the TCP sockets found on the system
#lsof -i TCP

To find out what process is holding TCP port 22
#lsof -i tcp:22

To show all resources that are being held by process id 2057
#lsof -p 2057

To find out what are the resources held by all cron processes. 
#lsof -o crond

To confirm resources that are being held by user id user linuser
#lsof -u linuser| more

To find out what are the processes that are locking the specify file /usr/sbin/anacron
# lsof /usr/sbin/anacron

Listing the files, any of whose IPv4 & IPv6 Internet address matches
# lsof -i4 -i6

Checking the count of open files
# lsof | wc -l

Listing of NFS files
#lsof -N

Hope it helps

No comments:

Post a Comment