Your first look
Outcome: bandwhich is running on your machine, you can point at every part of its screen and say what it is — and you got it running the honest way, by granting the privilege it asks for and understanding what that grant means.
Starting it: the privilege
Sniffing packets means watching traffic that belongs to every user and every program on the machine, so operating systems gate it. bandwhich needs the privilege before it shows anything, and there are two honest ways to give it.
Run it as root, one run at a time:
sudo bandwhich
Simple, and easy to audit: the privilege exists only while the display runs. This is the route to learn with.
Or grant the binary four capabilities, permanently. Linux can attach privileges to a program file itself, in slices called capabilities. bandwhich's own error message and documentation name the four it needs:
sudo setcap cap_sys_ptrace,cap_dac_read_search,cap_net_raw,cap_net_admin+ep $(command -v bandwhich)
The lab ran exactly this setcap
command, and getcap confirmed the
grant on the file (transcript
examples/transcripts/t11-proc-crossref.txt):
./bandwhich-cap cap_dac_read_search,cap_net_admin,cap_net_raw,cap_sys_ptrace=ep
What each slice is for, in plain words:
| Capability | What it lets bandwhich do |
|---|---|
cap_net_raw |
Open the raw packet sockets — the sniffing itself |
cap_net_admin |
The network administration operations the capture setup needs |
cap_sys_ptrace |
Look into other processes' open files, to name socket owners |
cap_dac_read_search |
Read past file-permission checks on that same hunt |
Read the table once more and the safety
point makes itself: a setcap grant is
standing permission for anyone who can
run that binary to watch the machine's
traffic and enumerate its processes'
sockets. On a single-user machine
that may be exactly what you want. On a
shared machine, prefer sudo per run,
so the privilege is lent, not left
lying around. Either way, only ever
watch traffic on machines and networks
you own or are authorised to monitor —
bandwhich shows metadata about other
programs' connections too, and "the
tool can see it" is not permission.
If neither grant is in place, you get
the refusal from chapter 3, exit code
1, and no display. That refusal is also
the check that the grant worked: after
setcap (or under sudo), the same
command opens the display instead.
The lab's detour, stated plainly
This guide's lab ran in a sandbox whose
kernel capability bounding set — the
ceiling no process in it can exceed —
does not contain cap_net_raw,
cap_net_admin, or cap_sys_ptrace at
all. The lab verified that three ways
(transcript t01): a direct packet
socket request failed with Operation
not permitted even as root; capsh
decoded the ceiling and the three
capabilities are simply absent; and a
correct setcap grant, confirmed on
the file, still refused at run time,
because the ceiling strips it. The lab
therefore ran its captures inside a
private network namespace — a
sandboxed network of its own, created
with unshare, where the lab's
processes did hold the capabilities
over their own loopback interface. The
detour changes nothing about bandwhich:
same binary, same flags, same output
format. It is recorded here and in
criteria.md because the series rule
is that the lab's road is part of the
evidence.
The screen
With the privilege in place — on your
machine, one sudo bandwhich — the
display opens. The lab captured it
under a real terminal during a real
transfer (transcript
examples/transcripts/t09-tui.txt, raw
capture t09-tui.raw). From the top:
- The header line names the
interface and the machine's total
rate, in and out:
IF: lo | Total Rate (Up / Down): 0.00B / 0.00Bwhen idle, and a live figure — the lab's capture shows889.31KiB / 0.00B— while traffic flows. - Three tables fill the rest of the screen, titled Utilization by process name, Utilization by remote address, and Utilization by connection. Each has the columns the next chapter takes apart: the thing being counted, how many connections it has, and its Rate (Up / Down).
- The display is responsive: shrink the window and it shows less — tables are dropped or narrowed to fit. A table missing from a small terminal has not vanished from the tool; it has been politely left off your screen. Chapter 7's one-table flags are the deliberate version of the same idea.
- Press
qto leave. The display is a live view, not a recording: when it closes, what it showed is gone, which is precisely the gap raw mode (chapter 7) exists to fill.
Check: start bandwhich, name the three
tables and the two numbers in the
header, and stop it with q. Then run
it once without the privilege and
read the refusal aloud — knowing both
faces of the tool is this chapter's
real outcome.