btop 命令详解与参数实测(Ubuntu 22.04)

在 Ubuntu 22.04(btop 1.2.3)上逐参数实测 btop:默认首屏四 box 逐区解读、-p 预设布局切换与越界负例、-t/+t tty 模式符号退化、-lc 低色、--utf-force 与 locale 报错闭环、--debug 日志取证、btop.conf 配置与主题体系、底栏键位速查,全部命令与抓屏真实可复现。

Linux命令系统监控Linux系统UbuntuUbuntu 22.04命令行2026/10/17

btop 命令详解与参数实测(Ubuntu 22.04)

目标:全面掌握 btop 的每一个命令行参数——默认首屏四 box 逐区解读、-p 预设布局切换与越界负例、-t/+t tty 模式符号退化、-lc 低色方案、--utf-force 与 locale 报错闭环、--debug 日志取证,以及 btop.conf 配置项与主题体系、底栏键位速查,全部命令与抓屏已在 Ubuntu 22.04(btop 1.2.3)实测通过。

一、环境信息

本篇所有命令均在以下环境中逐条实测,回显逐字照抄:

  • 操作系统:Ubuntu 22.04.5 LTS(代号 jammy)
  • 内核:6.8.0-138-generic(x86_64)
  • btop 版本:1.2.3(Ubuntu 22.04 官方仓库包 1.2.3-2,来自 jammy/universe)
  • CPU / 内存:12 逻辑核 / 31.2 GiB / Swap 2 GiB(以 btop 界面实显示为准)
  • 实测账号:root;终端规格 120 列 × 38 行;界面抓屏为真实终端输出还原

版本与环境实测回显:

$ grep PRETTY_NAME /etc/os-release
PRETTY_NAME="Ubuntu 22.04.5 LTS"

$ uname -r; uname -m
6.8.0-138-generic
x86_64

$ btop --version
btop version: 1.2.3

$ dpkg -l btop | tail -2
+++-==============-============-============-============================================================================
ii  btop           1.2.3-2      amd64        Modern and colorful command line resource monitor that shows usage and stats

$ apt-cache policy btop
btop:
  Installed: 1.2.3-2
  Candidate: 1.2.3-2
  Version table:
 *** 1.2.3-2 500
        500 http://archive.ubuntu.com/ubuntu jammy/universe amd64 Packages
        100 /var/lib/dpkg/status

二、命令概览

2.1 btop 是什么

btop(btop++)是 C++ 编写的单二进制资源监视器,界面元素比 top/htop 更重:CPU 每核历史曲线、内存分层条、磁盘 IO、网络吞吐图、进程表全部在一屏内以"box"(区块)组织,支持鼠标点击与丰富的主题系统。Ubuntu 22.04 仓库自带 1.2.3,apt install btop 即得。

2.2 语法与参数总表

btop --help 全文实测回显:

$ btop --help
usage: btop [-h] [-v] [-/+t] [-p <id>] [--utf-force] [--debug]

optional arguments:
  -h, --help            show this help message and exit
  -v, --version         show version info and exit
  -lc, --low-color      disable truecolor, converts 24-bit colors to 256-color
  -t, --tty_on          force (ON) tty mode, max 16 colors and tty friendly graph symbols
  +t, --tty_off         force (OFF) tty mode
  -p, --preset <id>     start with preset, integer value between 0-9
  --utf-force           force start even if no UTF-8 locale was detected
  --debug               start in DEBUG mode: shows microsecond timer for information collect
                        and screen draw functions and sets loglevel to DEBUG

btop 1.2.3 的命令行参数只有 8 个——它的扩展性全部沉淀在配置文件与运行时按键里(见第六、七章)。参数总表:

参数含义实测节
-h / --help帮助2.2
-v / --version版本1.1
-lc / --low-color24bit 真彩转 256 色4.4
-t / --tty_on强制 tty 模式(16 色 + tty 友好符号)4.3
+t / --tty_off强制关闭 tty 模式4.3
-p <id> / --preset以 0-9 号预设布局启动4.2
--utf-force无 UTF-8 locale 时强制启动4.5
--debug调试模式(μs 计时 + DEBUG 日志)4.6

注意 btop 的特色语法 [-/+t]:同一个开关用 -t 打开、+t 关闭,这是其它命令少见的加号开关风格。

三、默认首屏逐区解读

$ btop

实测抓屏(120×38 全屏,共享测试环境中另有少量其他会话进程如 nano/sh,如实保留):

╭─┐¹cpu┌──┐menu┌┐preset *┌──────────────────────────────┐03:01:20┌────────────────────────────────────────┐- 2000ms +┌─╮
│                                                                                                                      │
│                                                                             ╭─┐i7-14700KF┌─────────────────┐3.4 GHz┌╮│
│                                                                             │CPU ■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■   7%││
│                                                                            ⡇│C0  ⣀⣀⣀⣀⣀⣀⣀⣀⢀⢀   9%│C6  ⣀⣀⣀⣀⣀⣀⣀⣀⢀⢀   8%││
│                                                                            ⡇│C1  ⣀⣀⣀⣀⣀⣀⣀⣀⢀⢀   8%│C7  ⣀⣀⣀⣀⣀⣀⣀⣀⢀⢀   8%││
│                                                                           ⢠⣧│C2  ⣀⣀⣀⣀⣀⣀⣀⣀⢀⢀   8%│C8  ⣀⣀⣀⣀⣀⣀⣀⣀⢀⢀   7%││
│                                                                           ⠘⡟│C3  ⣀⣀⣀⣀⣀⣀⣀⣀⢀⣀   4%│C9  ⣀⣀⣀⣀⣀⣀⣀⣀⢀⢀   6%││
│                                                                            ⡇│C4  ⣀⣀⣀⣀⣀⣀⣀⣀⢀⢀   7%│C10 ⣀⣀⣀⣀⣀⣀⣀⣀⢀⣀   4%││
│                                                                            ⠃│C5  ⣀⣀⣀⣀⣀⣀⣀⣀⢀⢀  12%│C11 ⣀⣀⣀⣀⣀⣀⣀⣀⢀⢀   9%││
│                                                                             │                    LAV: 0.96 1.05 1.25││
│ up 03:28:54                                                                 ╰───────────────────────────────────────╯│
╰──────────────────────────────────────────────────────────────────────────────────────────────────────────────────────╯
╭─┐²mem┌──────────────────┬─┐disks┌─────────────┐io┌─╮╭─┐⁴proc┌┐filter┌────────┐per-core┌┐reverse┌┐tree┌┐< cpu lazy >┌─╮
│ Total:         31.2 GiB ├─swap────────────1.99─GiB─┤│    Pid: Program: Command:              User:  MemB       Cpu%  │
├─Used:──────────15.6─GiB─┤ Used:100% ■■■■■ 1.99 GiB ││    3205 timeout  timeout 3.2 btop      root   1.8M ⣀⣀⣀⣀⣀  0.0  │
│  50%                    │ Free:  0% ■■■■■ 3.91 MiB ││    2250 su       su demo -c sleep 3600 root   4.1M ⣀⣀⣀⣀⣀  0.0  │
│                       ⢸⣿│                          ││    2238 sleep    sleep 3600            root   1.5M ⣀⣀⣀⣀⣀  0.0  │
├─Available:─────15.6─GiB─├──────────────────────────┤│       1 sleep    sleep infinity        root   1.4M ⣀⣀⣀⣀⣀  0.0  │
│  50%                    │                          ││    1970 pkill                          root     0B ⣀⣀⣀⣀⣀  0.0  │
│                       ⢸⣿│                          ││    2216 pkill                          root     0B ⣀⣀⣀⣀⣀  0.0  │
├─Cached:────────12.2─GiB─┤                          ││    2231 bash     bash -c sleep 3600; s root   3.0M ⣀⣀⣀⣀⣀  0.0  │
│  39%                    │                          ││    2237 sleep    sleep 3600            root   1.5M ⣀⣀⣀⣀⣀  0.0  │
│                       ⢰⣶│                          ││    2256 bash     bash -c sleep 3600 &         2.9M ⣀⣀⣀⣀⣀  0.0  │
├─Free:───────────772─MiB─┤                          ││    2257 sleep    sleep 3600                   1.4M ⣀⣀⣀⣀⣀  0.0  │
│   2%                    │                          ││    2258 sleep    sleep 3600                   1.4M ⣀⣀⣀⣀⣀  0.0  │
│                         │                          ││    3047 sh                             root     0B ⣀⣀⣀⣀⣀  0.0  │
╰─────────────────────────┴──────────────────────────╯│    3048 nano                           root     0B ⣀⣀⣀⣀⣀  0.0  │
╭─┐³net┌┐172.17.0.29┌──┐sync┌┐auto┌zero┌┐<b eth0 n>┌─╮│    3053 sh                             root     0B ⣀⣀⣀⣀⣀  0.0  │
│10K                      ╭─┐download┌──────────────╮││    3054 nano                           root     0B ⣀⣀⣀⣀⣀  0.0  │
│                         │▼ 0 Byte/s      (0 bitps)│││    3059 sh                             root     0B ⣀⣀⣀⣀⣀  0.0  │
│                         │▼ Top:          (0 bitps)│││    3060 nano                           root     0B ⣀⣀⣀⣀⣀  0.0  │
│                       ⢀⣀│▼ Total:         88.1 MiB│││    3154 nano                           root     0B ⣀⣀⣀⣀⣀  0.0  │
│                       ⠈⠉│▲ 0 Byte/s      (0 bitps)│││    3211 btop     btop                  root   5.9M ⣀⣀⣀⣀⣀  0.0  │
│                         │▲ Top:          (0 bitps)│││                                                                │
│                         │▲ Total:          373 KiB│││                                                                │
│10K                      ╰─┘upload└────────────────╯│╰┘↑ select ↓└┘info ↲└┘terminate└┘kill└┘signals└────────────┘0/19└╯
╰────────────────────────────────────────────────────╯

逐区解读:

  • 顶栏:时间 03:01:20、刷新间隔 - 2000ms +(-/+ 键可调)、menu 与 preset * 入口。preset * 的星号表示当前未使用编号预设(手动改动过布局)。
  • ¹cpu box:右侧大图整体 CPU 曲线 + 型号 i7-14700KF 与主频(btop 直接读 /proc/cpuinfo 的 model name,所以显示的是宿主机 CPU);左下 C0-C11 每核一条 braille 迷你曲线(⣀⢀⡇⢸⣿ 等盲文字符即历史负载),最右 LAV: 0.96 1.05 1.25 负载均值;左侧竖向 braille 是温度/频率仪表。
  • ²mem box:内存分层条 Total/Used/Available/Cached/Free 各带独立百分比——比 top 单条 Mem 更细。
  • disks box:本环境 swap 显示 Used:100% 1.99 GiB(演示环境 swap 挂满,如实保留);io 角标切换 IO 视图。
  • ³net box:网卡名 eth0 与地址 172.17.0.29,download/upload 两条曲线,▼/▲ 当前后与前峰值,Total 累计流量;<b eth0 n> 提示 b 键切 bit/Byte、n 键切网卡。
  • ⁴proc box:进程表列头 Pid Program Command User MemB Cpu%,Cpu% 列自带 braille 迷你历史;box 标题行一排小开关 filter / per-core / reverse / tree / < cpu lazy > 是当前排序与过滤状态(点击或按键切换)。右上角 0/19 为选中位置/进程数。
  • 底栏:↑ select ↓ info ↲ terminate kill signals——方向键选进程、回车看详情、t terminate、k kill、_signals_ 打开信号菜单。

四、逐参数实测

4.1 -v / --version 与 -h / --help

$ btop -v
btop version: 1.2.3

$ btop -h
usage: btop [-h] [-v] [-/+t] [-p <id>] [--utf-force] [--debug]
…(同 2.2 全文,略)…

4.2 -p / --preset:预设布局(0-9)

-p 0 启动(与默认四 box 布局一致,顶栏 preset * 变为 preset 0,可从顶栏 grep 确认):

$ btop -p 0
╭─┐¹cpu┌──┐menu┌┐preset 0┌────────────────────────────┐03:01:2x┌────────────────────────────────────────┐- 2000ms +┌─╮
│ …(CPU/MEM/NET/PROC 四 box 同第三章默认布局)… 

-p 1 是另一种出厂布局——PROC box 拉宽占满右侧并多出 Threads 列,CPU box 压缩到左上角:

$ btop -p 1
│    Pid: Program:         Command:                                              Threads: User:       MemB       Cpu%  │
│    3236 timeout          timeout 3.2 btop -p 1                                        1 root        1.9M ⣀⣀⣀⣀⣀  0.0  │
│    2250 su               su demo -c sleep 3600 & sleep 3600 & wait                    1 root        4.1M ⣀⣀⣀⣀⣀  0.0  │

越界值 -p 99 直接拒绝且不启动界面:

$ btop -p 99
ERROR: Preset option only accepts an integer value between 0-9.

预设本体在 btop.conf 的 presets = "cpu:1:default,proc:0:default cpu:0:default,mem:0:default,net:0:default cpu:0:block,net:0:tty" 一行定义(空格分隔各预设,box:位置:图符号 格式,见 6.1),运行中按 1-9 数字键即时切换。

4.3 -t / --tty_on 与 +t / --tty_off:tty 模式

-t 强制 tty 模式:配色压到 16 色,图形符号全部换为 tty 友好字符。与默认首屏逐字符对比,两处肉眼可见的退化(已去除数字后 diff):

$ btop -t
# 默认(真彩 + Unicode):                     # -t(tty 模式):
╭─┐¹cpu┌──┐menu┌┐preset *┌──…                  ┌─┐1cpu┌──┐menu┌┐preset *┌──…
(box 圆角 ╭╮╰╯ + 上标 ¹²³⁴)                  (直角 ┌┐└┘ + 普通 1 2 3 4)

要点:

  • 圆角框线 ╭ ─ ╮ 退化为直角 ┌ ─ ┐
  • box 标题上标 ¹cpu ²mem ³net ⁴proc 退化为 1cpu 2mem 3net 4proc
  • braille 曲线同步换为 tty 字符集

适用场景:串口终端、老旧 TERM、真彩不支持的远程工具。+t 反向强制关闭 tty 模式(自动探测为 tty 但想用真彩时),本环境非 tty 探测,+t 后界面与默认一致。

4.4 -lc / --low-color:低色方案

$ btop -lc

抓屏文本与默认完全一致——-lc 只做 24-bit truecolor → 256-color 的色深降级,不改变任何字符与布局,差异只在 ANSI 颜色码里(6×6×6 色立方近似原色)。终端只支持 256 色时颜色发暗/失真用它。配置文件里对应 truecolor = True/False(见 6.1),-lc 相当于启动级临时覆盖。

4.5 --utf-force:强制以 UTF-8 启动

btop 启动时探测 locale,检测不到 UTF-8 直接拒绝(本环境 bash -c 下 LANG 未设置时复现,且写入 btop.log):

$ btop
ERROR: No UTF-8 locale detected!
Use --utf-force argument to force start if you're sure your terminal can handle it.

$ tail -3 ~/.config/btop/btop.log
2026/10/17 (03:00:37) | ERROR: No UTF-8 locale detected!
Use --utf-force argument to force start if you're sure your terminal can handle it.

此时要么补 locale(LC_ALL=C.UTF-8),要么按提示 --utf-force 强启——强启后界面正常渲染(本环境抓屏与默认一致),因为终端实际是 UTF-8 的,只是环境变量缺失。若终端真不支持 UTF-8,强启会得到乱码,此时应改用 -t tty 模式。

4.6 --debug:调试模式

$ btop --debug

界面顶部照常渲染,但日志切到 DEBUG 级并记录微秒级采集/绘制计时,实测 ~/.config/btop/btop.log 尾部:

2026/10/17 (03:06:05) | ===> btop++ v.1.2.3
2026/10/17 (03:06:05) | DEBUG: Starting in DEBUG mode!
2026/10/17 (03:06:05) | INFO: Logger set to DEBUG
2026/10/17 (03:06:05) | DEBUG: Using locale C.UTF-8
2026/10/17 (03:06:05) | INFO: Running on /dev/pts/1

报 btop 界面卡顿/渲染问题时,附上 --debug 产生的 btop.log 是标准取证姿势。

五、报错与边界实测

$ btop --bogus
 Unknown argument: --bogus
 Use -h or --help for help.

$ btop -p 99
ERROR: Preset option only accepts an integer value between 0-9.

$ btop          # 无 UTF-8 locale 的 shell 里
ERROR: No UTF-8 locale detected!
Use --utf-force argument to force start if you're sure your terminal can handle it.

三种报错风格一致:ERROR: 前缀 + 一句行动指引(Use -h… / Use --utf-force…),且启动失败均写 btop.log。注意 --bogus 前导是一个空格的 Unknown argument:——btop 1.2.3 原样如此。

六、配置文件与主题

6.1 btop.conf 关键项

首次运行自动生成 ~/.config/btop/btop.conf(实测 7895 字节,全部中文注释级说明),头部关键项:

$ ls -l ~/.config/btop/
-rw-r--r-- 1 root root 7895 Oct 17 03:00 btop.conf
-rw-r--r-- 1 root root  186 Oct 17 03:00 btop.log
drwxr-xr-x 2 root root 4096 Oct 17 03:00 themes

$ head -25 ~/.config/btop/btop.conf
#? Config file for btop v. 1.2.3

#* Name of a btop++/bpytop/bashtop formatted ".theme" file, "Default" and "TTY" for builtin themes.
#* Themes should be placed in "../share/btop/themes" relative to binary or "$HOME/.config/btop/themes"
color_theme = "Default"

#* If the theme set background should be shown, set to False if you want terminal background transparency.
theme_background = True

#* Sets if 24-bit truecolor should be used, will convert 24-bit colors to 256 color (6x6x6 color cube) if false.
truecolor = True

#* Set to true to force tty mode regardless if a real tty has been detected or not.
#* Will force 16-color mode and TTY theme, set all graph symbols to "tty" and swap out other non tty friendly symbols.
force_tty = False

#* Define presets for the layout of the boxes. Preset 0 is always all boxes shown with default settings. Max 9 presets.
#* Format: "box_name:P:G,box_name:P:G" P=(0 or 1) for alternate positions, G=graph symbol to use for box.
#* Use withespace " " as separator between different presets.
#* Example: "cpu:0:default,mem:0:tty,proc:1:default cpu:0:braille,proc:0:tty"
presets = "cpu:1:default,proc:0:default cpu:0:default,mem:0:default,net:0:default cpu:0:block,net:0:tty"

#* Set to True to enable "h,j,k,l" keys for directional control in lists.
#* Conflicting keys for h:"help" and k:"kill" is accessible while holding shift.

与命令行参数的对应关系:truecolor ↔ -lc、force_tty ↔ -t/+t、presets ↔ -p <id>。命令行是单次启动覆盖,conf 是持久默认。

6.2 主题体系

$ ls /usr/share/btop/themes/ | head -12
adapta.theme
ayu.theme
dracula.theme
dusklight.theme
flat-remix-light.theme
flat-remix.theme
greyscale.theme
gruvbox_dark.theme
gruvbox_dark_v2.theme
gruvbox_material_dark.theme
kyli0x.theme
matcha-dark-sea.theme

13+ 个出厂主题,改 color_theme = "gruvbox_dark" 重启生效;自定义主题放 ~/.config/btop/themes/ 即可被索引。运行中 Esc 打开菜单可切主题/预设/选项。

七、交互键位速查

键功能出处
Esc / m主菜单(选项/主题/预设/帮助)界面 menu 入口
1-9切换编号预设presets 注释
1/2/3/4(非预设态)聚焦 cpu/mem/net/proc boxbox 标题 ¹²³⁴
- / +刷新间隔 ±(默认 2000ms)顶栏 - 2000ms +
↑/↓ / 回车选进程 / 详情页底栏 select / info
t / kterminate(SIGTERM)/ kill(SIGKILL)底栏 terminate / kill
f进程过滤(等价 proc box 的 filter)proc box 标题
e树视图开关(等价 tree)proc box 标题
b网络速率 bit↔Bytenet box <b eth0 n>
n切换网卡net box <b eth0 n>
h j k lvim 方向键(conf 开关,默认关)btop.conf 注释
q / Esc Esc退出—

八、速查表

场景命令
版本 / 帮助btop -v / btop -h
以 1 号预设启动btop -p 1(合法域 0-9,越界报 ERROR)
老终端防乱码btop -t(16 色 + 直角符号);反之 btop +t
256 色终端btop -lc
locale 缺失强启btop --utf-force
界面问题取证btop --debug → ~/.config/btop/btop.log
持久化配色/布局~/.config/btop/btop.conf(truecolor/force_tty/presets)
换主题color_theme = "gruvbox_dark" 或 /usr/share/btop/themes/ 挑选
未知参数 Unknown argument: --bogus

一句话收束:btop 的命令行只有 8 个参数,核心是"启动姿势三件套"——-p 选布局、-t/+t 控符号、-lc 控色深;其余一切(主题、排序、过滤、键位)都进 btop.conf 或运行时按键,这正是它把 top/htop 的"参数海"收敛为"配置流"的设计取向。