- trixie 2.41-5
- testing 2.41.3-4
- unstable 2.41.3-4
- experimental 2.42~rc2-1
| LSFD(1) | User Commands | LSFD(1) |
NAME¶
lsfd - list file descriptors
SYNOPSIS¶
lsfd [option]
DESCRIPTION¶
lsfd is intended to be a modern replacement for lsof(8) on Linux systems. Unlike lsof, lsfd is specialized to Linux kernel; it supports Linux specific features like namespaces with simpler code. lsfd is not a drop-in replacement for lsof; they are different in the command line interface and output formats.
The default output is subject to change. So whenever possible, you should avoid using default outputs in your scripts. Always explicitly define expected columns by using --output columns-list in environments where a stable output is required.
lsfd uses Libsmartcols for output formatting and filtering. See the description of --output option for customizing the output format, and --filter option for filtering. Use lsfd --list-columns to get a list of all available columns.
OPTIONS¶
-l, --threads
-J, --json
-n, --noheadings
-o, --output list
The default list of columns may be extended if list is specified in the format +list (e.g., lsfd -o +DELETED).
-r, --raw
--notruncate
-p, --pid list
-i[4|6], --inet[=4|=6]
-Q, --filter expression
The -Q option with a PID (for example: -Q PID==1) and the -p option (for example: -p 1) can be used to achieve the same result, but using the -p option is much more efficient because it works at a much earlier stage of processing than the -Q option.
-C, --counter label:filter_expr
See scols-filter(5) about filter_expr. label should not include { nor :. You can define multiple counters by specifying this option multiple times. See also COUNTER EXAMPLES.
--summary[=mode]
The summary reports counters. A counter consists of a label and an integer value. --counter is the option for defining a counter. If a user defines no counter, lsfd uses the definitions of pre-defined built-in counters (default counters) to make the summary output.
CAUTION: Using --summary and --json may make the output broken. Only combining --summary=only and --json is valid.
--debug-filter
--dump-counters
--hyperlink[=when]
-H, --list-columns
-h, --help
-V, --version
ENVIRONMENT¶
LIBSMARTCOLS_DEBUG=all
LIBSMARTCOLS_DEBUG_PADDING=on
LIBSMARTCOLS_JSON=compact|lines
OUTPUT COLUMNS¶
Each column has a type. Types are surround by < and >.
CAUTION: The names and types of columns are not stable yet. They may be changed in the future releases.
AINODECLASS <string>
ASSOC <string>
BLKDRV <string>
BPF-MAP.ID <number>
BPF-MAP.TYPE <string>
BPF-MAP.TYPE.RAW <number>
BPF.NAME <string>
BPF-PROG.ID <number>
BPF-PROG.TAG <string>
BPF-PROG.TYPE <string>
BPF-PROG.TYPE.RAW <number>
CHRDRV <string>
COMMAND <string>
DELETED <boolean>
DEV <string>
DEVTYPE <string>
ENDPOINTS <string>
lsfd collects endpoints within the processes that lsfd scans; lsfd may miss some endpoints if you limits the processes with -p option.
The format of the column depends on the object associated with the fd:
FIFO type, mqueue type, ptmx and pts sources
The last characters ([-r][-w]) represent the read and/or write mode of the endpoint.
eventfd type
UNIX
In a container, lsfd may not fill ENDPOINTS column. lsfd uses sock_diag(7) to collect information about UNIX endpoints. SELinux may limit the use sock_diag in a container. You can remove the limit by setting 1 to virt_sandbox_use_netlink bool. See container_selinux(8) for more details.
UNIX-STREAM
About the last characters ([-r?][-w?]), see the description of SOCK.SHUTDOWN.
EVENTFD.ID <number>
EVENTPOLL.TFDS <string>
FD <number>
FLAGS <string>
FUID <number>
INET.LADDR <string>
INET.RADDR <string>
INET6.LADDR <string>
INET6.RADDR <string>
INODE <number>
INOTIFY.INODES <string>
INOTIFY.INODES.RAW <string>
KNAME <string>
KTHREAD <boolean>
MAJ:MIN <string>
MAPLEN <number>
MISCDEV <string>
MNTID <number>
MODE <string>
NAME <string>
Some files have special formats and information sources:
AF_VSOCK
raddr is not shown for listening sockets.
bpf-map
bpf-prog
eventpoll
eventfd
inotify
misc:tun
NETLINK
PACKET
pidfd
lsfd extracts TARGET-PID and TARGET-NSPIDS from /proc/pid/fdinfo/fd.
PING
PINGv6
ptmx
lsfd extracts PTMX.TTY-INDEX from /proc/pid/fdinfo/fd.
RAW
RAWv6
signalfd
TCP, TCPv6
timerfd
UDP, UDPv6
lsfd hides raddr= if UDP.RADDR is 0.0.0.0 and UDP.RPORT is 0.
UDP-LITE, UDPLITEv6
UNIX-STREAM
UNIX
Note that (deleted) markers are removed
from this column. Refer to KNAME, DELETED, or XMODE to
know the readability of the file from the file system.
NETLINK.GROUPS <number>
NETLINK.LPORT <number>
NETLINK.PROTOCOL <string>
NLINK <number>
NS.NAME <string>
NS.TYPE <string>
OWNER <string>
PACKET.IFACE <string>
PACKET.PROTOCOL <string>
PACKET.PROTOCOL.RAW <number>
PARTITION <string>
PID <number>
PIDFD.COMM <string>
PIDFD.NSPID <string>
Quoted from kernel/fork.c of Linux source tree:
If pid namespaces are supported then this function will also print the pid of a given pidfd refers to for all descendant pid namespaces starting from the current pid namespace of the instance, i.e. the Pid field and the first entry in the NSpid field will be identical.
Note that this differs from the Pid and NSpid fields in
/proc/<pid>/status where Pid and NSpid are always shown relative to
the pid namespace of the procfs instance.
PIDFD.PID <number>
PING.ID <`number`>
POS <number>
RAW.PROTOCOL <string>
Note
The data type of this column was <number> from v2.39 to v2.41.
RAW.PROTOCOL.RAW <number>
RDEV <string>
SIGNALFD.MASK <string>
SIZE <number>
SOCK.LISTENING <boolean>
SOCK.NETS <number>
SOCK.PROTONAME <string>
SOCK.SHUTDOWN <string>
[-r?]
[-w?]
SOCK.STATE <string>
SOCK.TYPE <string>
SOURCE <string>
STTYPE <string>
TCP.LADDR <string>
TCP.LPORT <number>
TCP.RADDR <string>
TCP.RPORT <number>
TID <number>
TIMERFD.CLOCKID <string>
TIMERFD.INTERVAL <number>
TIMERFD.REMAINING <number>
PTMX.TTY-INDEX <number>
TUN.DEVNETNS <number>
TUN.IFACE <string>
TYPE <string>
If lsfd gets an error when calling a syscall to know about a target file descriptor, lsfd fills this column for it with ERROR.
UDP.LADDR <string>
UDP.LPORT <number>
UDP.RADDR <string>
UDP.RPORT <number>
UDPLITE.LADDR <string>
UDPLITE.LPORT <number>
UDPLITE.RADDR <string>
UDPLITE.RPORT <number>
UID <number>
UNIX.IPEER < number >
If lsfd runs in a container, it may not fill UNIX.IPEER column. See the description of UNIX in ENDPOINTS column for more details.
UNIX.PATH <string>
USER <string>
VSOCK.LADDR <string>, VSOCK.RADDR <string>
Well-known CIDs will be decoded: “*”, “hypervisor”, “local”, or “host”. Well-known ports will be decoded: “*”.
VSOCK.LCID <number>, VSOCK.RCID <number>
VSOCK.LPORT <number>, VSOCK.RPORT <number>
XMODE <string>
[-r]
[-w]
[-x]
[-D]
[-Ll]
[-m]
FILTER EXAMPLES¶
lsfd has few options for filtering. In most of cases, what you should know is -Q (or --filter) option. Combined with -o (or --output) option, you can customize the output as you want.
List files associated with PID 1 and PID 2 processes:
# lsfd -Q '(PID == 1) or (PID == 2)'
Do the same in an alternative way:
# lsfd -Q '(PID == 1) || (PID == 2)'
Do the same in a more efficient way:
# lsfd --pid 1,2
Whitespaces can be used instead of a comma:
# lsfd --pid '1 2'
Utilize pidof(1) for list the files associated with "firefox":
# lsfd --pid "$(pidof firefox)"
List the 1st file descriptor opened by PID 1 process:
# lsfd -Q '(PID == 1) and (FD == 1)'
Do the same in an alternative way:
# lsfd -Q '(PID == 1) && (FD == 1)'
List all running executables:
# lsfd -Q 'ASSOC == "exe"'
Do the same in an alternative way:
# lsfd -Q 'ASSOC eq "exe"'
Do the same but print only file names:
# lsfd -o NAME -Q 'ASSOC eq "exe"' | sort -u
List deleted files associated to processes:
# lsfd -Q 'DELETED'
List non-regular files:
# lsfd -Q 'TYPE != "REG"'
List block devices:
# lsfd -Q 'DEVTYPE == "blk"'
Do the same with TYPE column:
# lsfd -Q 'TYPE == "BLK"'
List files including "dconf" directory in their names:
# lsfd -Q 'NAME =~ ".\*/dconf/.*"'
List files opened in a QEMU virtual machine:
# lsfd -Q '(COMMAND =~ ".\*qemu.*") and (FD >= 0)'
List timerfd files expired within 0.5 seconds:
# lsfd -Q '(TIMERFD.remaining < 0.5) and (TIMERFD.remaining > 0.0)'
List processes communicating via unix stream sockets:
# lsfd -Q 'TYPE == "UNIX-STREAM" && UNIX.PATH =~ ".+"' -oUNIX.PATH,PID,COMMAND,FD,SOCK.STATE,ENDPOINTS
List processes communicating via a specified unix stream socket:
# lsfd -Q 'TYPE == "UNIX-STREAM" && UNIX.PATH == "@/tmp/.X11-unix/X0"' -oUNIX.PATH,PID,COMMAND,FD,SOCK.STATE,ENDPOINTS
COUNTER EXAMPLES¶
Report the numbers of netlink socket descriptors and unix socket descriptors:
# lsfd --summary=only \
-C 'netlink sockets':'(NAME =~ "NETLINK:.*")' \
-C 'unix sockets':'(NAME =~ "UNIX:.*")' VALUE COUNTER
57 netlink sockets
1552 unix sockets
Do the same but print in JSON format:
# lsfd --summary=only --json \
-C 'netlink sockets':'(NAME =~ "NETLINK:.*")' \
-C 'unix sockets':'(NAME =~ "UNIX:.*")' {
"lsfd-summary": [
{
"value": 15,
"counter": "netlink sockets"
},{
"value": 798,
"counter": "unix sockets"
}
] }
HISTORY¶
The lsfd command is part of the util-linux package since v2.38.
AUTHORS¶
Masatake YAMATO <yamato@redhat.com>, Karel Zak <kzak@redhat.com>
SEE ALSO¶
bpftool(8), bps(8), lslocks(8), lsof(8), pidof(1), proc(5), scols-filter(5), socket(2), ss(8), stat(2), vsock(7)
REPORTING BUGS¶
For bug reports, use the issue tracker <https://github.com/util-linux/util-linux/issues>.
AVAILABILITY¶
The lsfd command is part of the util-linux package which can be downloaded from Linux Kernel Archive <https://www.kernel.org/pub/linux/utils/util-linux/>.
| 2026-03-19 | util-linux 2.42-rc2 |