lsof Command Introduction:
Lsof (list open files) is a tool that lists open files for the current system. In a Linux environment, everything is in the form of files, with files that not only access regular data, but also access to network connectivity and hardware. So, Lsof is a powerful feature. The general root user can execute the lsof command, and the normal user will see the/usr/sbin/lsof command, but normal user execution displays "permission denied". It is therefore helpful to see this list through the Lsof tool for system monitoring and troubleshooting.
Usage: [-?ABHLNNOOPRSTUVV] [+|-c c] [+|-d s] [+d d] [+|-F[CGG]]
[-F [F]] [-G [S]] [-I [i]] [+|-l [L]] [+|-m] [-O [O]]
[-P S] [+|-r [T]] [-S [t]] [-t [T]] [U S] [+|-w] [-X [FL]] [--] [Names]
As you can see, Lsof has a really surprising number of options. You can use it to get information about the device on your system, and you can learn what the specified user is touching at the specified location, or even what file or network connection a process is using.
For me, lsof replaced the whole work of Netstat and PS. It can bring everything that those tools can bring, and much more than those tools. So, let's take a look at some of its basic capabilities:
Enter lsof at the terminal to display the file opened by the system, because lsof needs to access core memory and various files, so it must be run as root to fully perform its functions.
Powerful lsof command using Linux system