The Config File
Outcome: you can find btop's config file, read the settings that matter, change one by hand in a text editor, and prove the change on a relaunch — and you know the one rule that decides whether any setting survives: btop writes the file when it quits cleanly, and only then.
Where it lives, and when it is written
The file is ~/.config/btop/btop.conf.
An alternate can be named on the
command line (btop -c somefile.conf),
and btop --default-config prints the
stock version — every setting at its
factory value, each under a comment
explaining it — which is both the
documentation and the way back if an
edit goes wrong.
The writing rule deserves its own
paragraph, because the lab broke it
repeatedly before believing it: btop
saves its settings on a clean exit —
q, Ctrl+C, or QUIT in the menu. Close
its terminal window, kill it, or let
the machine die underneath it, and
everything changed in that sitting is
gone. The lab's first theme change
(chapter 6) was lost exactly this way
when that early copy of btop died
mid-sitting on a memory-starved
machine; the change had to be made
again, in a sitting that ended
properly, before the file would admit
it had ever happened. Think of the
options screen as a notebook btop
copies into the file only when it
leaves politely.
Reading it
The file is plain text: one
name = value per setting, grouped
under comments that explain each one.
Four settings found in the lab's file
cover most of what this guide has done:
color_theme = "Default"
shown_boxes = "cpu mem net proc"
update_ms = 2000
proc_tree = false
- color_theme — the theme name from
chapter 6. After the lab re-made its
change and quit cleanly, this line in
a test config read
color_theme = "TTY": the receipt that options changes land here. - shown_boxes — which boxes open at
startup, as words. Chapter 7's trap
was this line caught reading
"cpu net"after a quit under a preset. - update_ms — the refresh interval
in milliseconds; 2000 as installed.
Lower is smoother and costs more of
the very processor you are measuring;
the
+/-keys adjust the same number live. - proc_tree — whether the process list opens in tree view (chapter 4).
Alongside them sit the presets line
(chapter 7), graph_symbol choices
(braille as installed), the per-box
settings the options tabs edit, and
one the help screen mentioned:
proc_sorting = "cpu lazy" — the sort
the list opens with, which is why the
lab's list always came up in that
order.
Changing one by hand: the worked example
The point of a readable file is editing it. The lab wanted tree view (chapter 4) to be its starting view, so, with btop not running, it changed one word:
sed -i 's/^proc_tree = false/proc_tree = true/' ~/.config/btop/btop.conf
grep '^proc_tree' ~/.config/btop/btop.conf
proc_tree = true
(Any text editor does the same job; the
sed form is shown because it can be
checked, as here, by printing the line
back.) Relaunching btop brought the
process box up already unfolded as a
tree — the same capture chapter 4
shows — with no key pressed. That is
the proof pattern for every edit in
this file: change the line, print it
back, relaunch, see it.
Two handshakes complete the picture.
Ctrl+R inside btop reloads the
file from disk, so an edit made in
another window takes effect without a
relaunch — and, symmetrically, btop
will overwrite the file at quit with
the state it holds, so an edit made
to the file while btop runs, without
Ctrl+R, is an edit the quit will
silently replace. And if the file is
deleted, btop falls back to its
defaults and writes a fresh one on
exit — the lab's first runs proved
exactly that path, since no file
existed until btop made one — so the
nuclear option is also the recovery,
and --default-config lets you
preview exactly what you would be
resetting to.
Check: find your btop.conf, read its
shown_boxes and update_ms, and if
you change either, quit btop cleanly
and read the file again — the file
should now say what the screen showed
when you left.