A file is opened or there may not be a file descriptor, such as current working diretories,memory mapped files and executable text files; losf can check the number of files opened by a process:
[Email protected] ~]# Shsh-4.1# lsof |grep1407Rpcbind1407RPC CWD DIR253,0 4096 2/Rpcbind1407RPC RTD DIR253,0 4096 2/Rpcbind1407RPC txt REG253,0 54560 784900/sbin/Rpcbindrpcbind1407RPC Mem REG253,0 65960 1439007/lib64/libnss_files-2.12. Sorpcbind1407RPC Mem REG253,0 19536 1438997/lib64/libdl-2.12. Sorpcbind1407RPC Mem REG253,0 36584 1438992/lib64/libgssglue.so.1.0.0Rpcbind1407RPC Mem REG253,0 113432 1439001/lib64/libnsl-2.12. Sorpcbind1407RPC Mem REG253,0 1923352 1438991/lib64/libc-2.12. Sorpcbind1407RPC Mem REG253,0 142688 1439015/lib64/libpthread-2.12. Sorpcbind1407RPC Mem REG253,0 166976 1438998/lib64/libtirpc.so.1.0.TenRpcbind1407RPC Mem REG253,0 40792 1439080/lib64/libwrap.so.0.7.6Rpcbind1407RPC Mem REG253,0 154664 1438979/lib64/ld-2.12. Sorpcbind1407Rpc0uCHR1,30t03857/dev/NULLRpcbind1407Rpc1uCHR1,30t03857/dev/NULLRpcbind1407Rpc2uCHR1,30t03857/dev/NULLRpcbind1407RPC 3r REG253,0 0 133514/var/run/rpcbind.LockRpcbind1407Rpc4uSock0,60t09743Aa'T Identify protocolRpcbind1407Rpc5uUnix0xffff88003742b4800t09658/var/run/Rpcbind.sockrpcbind1407Rpc6uIPv496600t0 UDP *: Sunrpc rpcbind1407Rpc7uIPv496620t0 UDP *:734Rpcbind1407Rpc8uIPv496630t0 TCP *: Sunrpc (LISTEN) Rpcbind1407Rpc9uIPv696650t0 UDP *: Sunrpc rpcbind1407Rpc10uIPv696670t0 UDP *:734Rpcbind1407Rpc11uIPv696680t0 TCP *: Sunrpc (LISTEN) SH-4.1# lsof |grep1407|WC-L -
The following methods are used to query the number of file descriptors used by the process:
sh-4.1# ls-l/proc/1407/Fdtotal0lrwx------1Root root -Nov at Ten: - 0/dev/NULLlrwx------1Root root -Nov at Ten: - 1/dev/NULLlrwx------1Root root -Nov at Ten: - Tensocket:[9667]lrwx------1Root root -Nov at Ten: - Onesocket:[9668]lrwx------1Root root -Nov at Ten: - 2/dev/NULLLR-X------1Root root -Nov at Ten: - 3/var/run/rpcbind.Locklrwx------1Root root -Nov at Ten: - 4socket:[9743]lrwx------1Root root -Nov at Ten: - 5socket:[9658]lrwx------1Root root -Nov at Ten: - 6socket:[9660]lrwx------1Root root -Nov at Ten: - 7socket:[9662]lrwx------1Root root -Nov at Ten: - 8socket:[9663]lrwx------1Root root -Nov at Ten: - 9socket:[9665]sh-4.1# ls-l/proc/1407/FD|WC-L -
Process 1407 opens 24 files in total, and consumes only 13 file descriptors
To view the settings for a file descriptor:
sh-4.1# cat/proc/sys/fs/file-1000000--This parameter can be modified dynamically
Linux file descriptor the difference between open file descriptors and open files