Lsof installation




















In no particular order of usefulness, here are some useful and commonly-used commands incorporating lsof. For a more detailed description of lsof enter man 8 lsof in the terminal and use h to navigate. In some cases, your password will not show when entered, this is completely normal.

For reference the remaining examples will be executed in Ubuntu. Note: Files can be normal files, as well as directories, sockets, and more in Linux. Syntax: lsof [ -? FD stands for file descriptor which can take on various values. NAME refers to the file's location and mount point, but can reference other values as well Some Useful Commands In no particular order of usefulness, here are some useful and commonly-used commands incorporating lsof.

This parameter when specified instructs lsof to repeat the command at the specified time interval. In the example below we are repeating the command every 5 seconds. To list all network connections on your system you can issue the lsof command with the " -i " parameter. If you want to see only TCP connections, you can use " lsof -i tcp " and for "UDP" connection you can issue the command " lsof -i udp ". In the example below, we have specified port This is the default port for ssh connections.

We can see from the output that the ssh daemon is listening on port 22 for connections and that a connection has been established from the remote IP address of " You also issue the command specifying a process to look for.

In this example, we have specified the string " ssh " and " httpd ":. To specify a range of ports, we can specify the range of ports to check. In the example below, we are checking for all connections on ports 22 through to On occasion, you may notice that the " df " command reports that you have less space available within a filesystem.

When you look for files that are using space using conventional commands like "ls" and "du", you will find that there are no listed files consuming space. You cannot visibly see any files that are consuming space.

The "lsof" command can help here as it will allow you to identify unlinked files that are holding onto space. A technique often used within programming is to create a temporary file and then unlink the file. This coding technique will leave the file and its available space available to the executing program.

Sometimes programmes do not exit cleanly and can leave these unlinked files holding onto space. To determine if you have a process holding onto an unlinked file, you can issue the following command:.

Unix and Linux Training 6 Lectures 4 hours Uplatz. Previous Page Print Page. Save Close. These two equivalent options select a usage help output list. Lsof displays a shortened form of this output when it detects an error in the options supplied to it, after it has displayed messages explaining each error. It allows the lsof user to specify A as an alternate name list file where the kernel addresses of the dynamic modules might be found.

This option causes lsof to avoid kernel functions that might block - lstat, readlink, and stat. This option selects the listing of files for processes executing the command that begins with the characters of c. Multiple commands may be specified, using multiple -c options. This option disables the ratio of the components of path names of the kernel name cache.

This option tells lsof to search for all open instances of directory s and the files and directories it contains the first level. This option does NOT descend into the root directory tree s , and does not follow symbolic links within it. This option selects the listing of files whose descriptors are present in all s comma-separated - eg, "1.

There should not be any spaces in the set. This option tells lsof to search for all open instances of directory D and all files and directories it contains to its maximum depth. Symbolic links within the directory D are ignored, ie d. This option forces the use of the file cache devices by lsof. Using this option may be prohibited. This option specifies a list of characters, f , that selects the fields to go out for a treatment with another program, and the character that terminates each output field.

Each field is specified to produce a single character in f. This option selects the listing of files for the processes whose number IDentification process group group ID is present in all s comma-separated - eg, "" or ", This option selects the listing of files whose Internet address matches the address specified with i.



0コメント

  • 1000 / 1000