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 READED TODAY
- Creating splitted rar archive files
- Converting MAC dfonts to TrueType
- XFS Filesystem has duplicate UUID problem
- Network interface status with mii-tool
- Recovering Root Password
- Recovering mysql root password
- Changing time in Linux
- Listing files by size
- Search and replace on multiple files
- Solving ssh problems
LAST ADDED
- Routing packets back from incoming interface
- Users with /bin/false shell to login on vsftpd
- Redirecting TCP ports with redir
- Assembly code of a C code
- Network interface status with mii-tool
- dropbear rsa key problem
- Displaying disk io statistics
- Disabling ssh password authentication
- Creating splitted rar archive files
- Creating self-extracting zip archives for both Linux and Windows

Nice tip ! Thanks.