Using lsof utility
lsof is one of the little known but very powerfull utility in Linux. Man pages basically says that lsof: list open files. But you can use it for managing and tracking network connections, you can list open ports, identify connections currently being made to your system, and determine what resources a process is using. Not only that, but you can also determine what processes a particular user has and find detailed information about file and directory usage. Here some example usages:
List all open files in system:
lsof
List all network connections:
lsof -i
List all UDP connections:
lsof -iUDP
List connections on specific port number:
lsof -i :80
List connections on specific host:
lsof -i@10.105.2.3
List connection on specifics host and port:
lsof -i@10.105.2.3:80
List all files opened by user fred:
lsof -u fred
List all files which opened by specific command:
lsof -c mysqld
List all process which using a specific file:
lsof /var/run/mysqld/mysqld.sock
List all processes which opens files under specific directory:
lsof +d /etc/passwd
List all the open files used by a specific process with process id:
lsof -p 8729
- 1 Comment
- Murat Demirten
- 23 Jun 2008, 13:14
-
sign-up for an account to post comments.
Maybe you should look at these also:
USERBOX
CATEGORIES
MOST READ TODAY
- Redirecting tcp / udp ports with socat
- Syntax highlighting in less
- Disabling reverse dns lookups in ssh
- Passwordless sudo setup
- Users with /bin/false shell to login on vsftpd
- Using lsof utility
- Scp resume
- Enabling remote desktop on a VirtualBox Machine
- XFS Filesystem has duplicate UUID problem
- dropbear rsa key problem
LAST ADDED
- Using iPhone internet sharing over bluetooth under Linux
- Using USB sound card with amarok
- Multi-conditional search and replace (clearing a ftp trojan script example)
- Disabling ipv6 functionality
- How to convert a mp3 file
- How to choose the fastest Debian mirror
- Disabling reverse dns lookups in ssh
- Rewriting destination ip address
- Deleting A File By It's Inode Value
- Learning which libraries are used for a binary

Nice tip ! Thanks.