Linux lsof using __linux

Source: Internet
Author: User

Lsof (list open files) is a tool that lists the current system open file. In a Linux environment, everything exists as a file, and access to network connections and hardware can be accessed through files, not just regular data.

Enter lsof under the terminal to display the system's open files, because the lsof needs access to core memory and various files, so it must be run as root to fully perform its functions.

[Root@master ~]# lsof-p 22529
COMMAND PID USER FD TYPE DEVICE SIZE NODE NAME
Java 22529 Hadoop cwd DIR 8,3 4096 68255745/home/hadoop/hadoop-1.0.3
Java 22529 Hadoop RTD DIR 8,3 4096 2/
Java 22529 Hadoop txt REG 8,3 270055 62390291/home/hadoop/jrockit-jdk1.6.0_29/bin/java
Java 22529 Hadoop mem REG 8,3 144776 19431601/lib64/ld-2.5.so
Java 22529 Hadoop mem REG 8,3 1726320 19431605/lib64/libc-2.5.so
Java 22529 Hadoop mem REG 8,3 614992 19431684/lib64/libm-2.5.so
Java 22529 Hadoop mem REG 8,3 23360 19431672/lib64/libdl-2.5.so
Java 22529 Hadoop mem REG 8,3 149968 19431652/lib64/libpthread-2.5.so
Java 22529 Hadoop mem REG 8,3 53448 19431661/lib64/librt-2.5.so
Java 22529 Hadoop mem REG 8,3 114352 19431671/lib64/libnsl-2.5.so
Java 22529 Hadoop mem REG 8,3 92816 19431752/lib64/libresolv-2.5.so
Java 22529 Hadoop mem REG 8,3 23684216 62456020/home/hadoop/jrockit-jdk1.6.0_29/jre/lib/amd64/jroc Kit/libjvm.so
Java 22529 Hadoop mem REG 8,3 492348 62456055/home/hadoop/jrockit-jdk1.6.0_29/jre/lib/amd64/libo Sal.so
Java 22529 Hadoop mem REG 8,3 233295 62456060/home/hadoop/jrockit-jdk1.6.0_29/jre/lib/amd64/libu Til.so
Java 22529 Hadoop mem REG 8,3 32768 112656417/tmp/hsperfdata_hadoop/22529
Java 22529 Hadoop mem REG 8,3 53880 19431603/lib64/libnss_files-2.5.so
Java 22529 Hadoop mem REG 8,3 261428 62456041/HOME/HADOOP/JROCKIT-JDK1.6.0_29/JRE/LIB/AMD64/LIBJ Fr.so
Java 22529 Hadoop mem REG 8,3 66580 62456061/HOME/HADOOP/JROCKIT-JDK1.6.0_29/JRE/LIB/AMD64/LIBV Erify.so
Java 22529 Hadoop mem REG 8,3 234440 62456036/HOME/HADOOP/JROCKIT-JDK1.6.0_29/JRE/LIB/AMD64/LIBJ Ava.so
Java 22529 Hadoop mem REG 8,3 55818 62488580/home/hadoop/jrockit-jdk1.6.0_29/jre/lib/amd64/nati Ve_threads/libhpi.so
Java 22529 Hadoop mem REG 8,3 56471376 16979795/usr/lib/locale/locale-archive
Java 22529 Hadoop mem REG 8,3 92253 62456062/home/hadoop/jrockit-jdk1.6.0_29/jre/lib/amd64/libz Ip.so
Java 22529 Hadoop mem REG 8,3 39481 62456047/HOME/HADOOP/JROCKIT-JDK1.6.0_29/JRE/LIB/AMD64/LIBM Anagement.so

COMMAND: The name of the process
PID: Process Identifier
USER: Process Owner
FD: A file descriptor that the application recognizes by the file descriptor. such as CWD, TXT, etc.
Type: File types, such as Dir, Reg, etc.
DEVICE: Specifies the name of the disk
Size: Sizes of files
Node: Index node (identity of file on disk)
Name: Open the exact name of the file

Where the file descriptor in the FD column

The CWD value represents the current working directory of the application, which is the directory that the application starts, unless it makes changes to the directory itself.

TXT-type files are program code, such as the application binaries themselves or shared libraries, such as the/sbin/init program shown in the list above. The second value represents the file descriptor for the application, which is an integer that is returned when the file is opened. As the last line on the file/dev/initctl, its file descriptor is 10. U indicates that the file is open and in read/write mode, not read-only or write-only (w) mode. There is also an uppercase w indicating that the application has a write lock on the entire file. This file descriptor is used to ensure that only one instance of the application can be opened at a time. When each application is initially opened, it has three file descriptors, from 0 to 2, representing standard input, output, and error streams, respectively. So most applications open files with FD starting at 3. The Type column is more intuitive than the FD column. Files and directories are called REG and DIR, respectively. CHR and BLK, respectively, represent characters and block devices, or UNIX, FIFO, and IPv4, which represent UNIX domain sockets, first-in first-out (FIFO) queues, and Internet Protocol (IP) sockets, respectively.  

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.