bpftool: tool for inspection and simple manipulation of eBPF programs and maps
bpftool [OPTIONS] OBJECT { COMMAND | help }
What it does
bpftool lists and inspects the eBPF programs and maps loaded in the kernel, the kernel's BTF, and what the kernel supports. It is part of the kernel source; on Ubuntu it is the bpftool package. It needs root.
Options you will use
-j, --json- JSON output.
-p, --pretty- pretty JSON.
-V, --version- print version.
Examples
$ sudo bpftool prog listloaded eBPF programs
$ sudo bpftool feature probe kernel | grep -i unprivilegedwho may load BPF
$ bpftool btf dump file /sys/kernel/btf/vmlinux format c | headthe kernel types as C
Gotchas
- As a normal user: "Error: can't get next program: Operation not permitted".
- Programs from a bcc tool or bpftrace disappear when the tool exits: sudo bpftool prog list afterwards shows nothing is left attached.
Taught in
Try bpftool in a real terminal Free, in your browser - a real Ubuntu terminal to try it in, with missions that check your work.