Linux lsof Command - Its examples and usage

Linux lsof Command - Its examples and usage

LSOF Command:

LSOF command is a list open command. This command is widely used in server Administrator. Lsof command is used to declare the files that are opened via process. In linux system everything is treat as a file like sockets, devices, pipes etc. with the help of lsof command we show the information of all file that are opened. Lsof command is comes with option that you can use to get the information about any opened file.

Usages of lsof command with option:

1. For see the list of all open file use the following command.

Syntax:

#lsof

It shows the list of all opened file with information such as user, PID, TYPE, and FD etc.

2. For see the list of specific user’s opened file then use the following command.

Syntax:

# lsof –u user_name


3. For see the running process on port use the given command.

Syntax:

# - i port_number

4. For see the list of open files of IPv6 and IPv4 file use the given command.

Syntax:

# lsof – i 4 – For IPv4

# lsof – i 6 – For IPv6



5. If you want to see the list of particular port with range for example TCP port range 1-1024 then used the following command.

Syntax:

# lsof – i :1-1024

6. If you want to list with specific PID then use the following command

Syntax:

# lsof – p PID

7. If you want to kill the activity for specific user via using the lsof command.

Syntax:

# killall – 9 ‘lsof – t – u username’

8. If you want to see the list of open file of directory.

Syntax:

# lsof +D Directory Path.

9. If you want to see the list of open files of specific process name.

Syntax:

# lsof – c process_name

10. For see the list of network connections.

Syntax:

# lsof – i.
Author
Jaishree
Views
1,820
First release
Last update
Rating
0.00 star(s) 0 ratings
Top