mcpField
B
btop

btop

官方精选
github.com开发者工具35.2kbtop今天更新
代码仓库访问官网

关于 btop

btop 是一款功能丰富的资源监控工具,提供实时的系统和进程指标展示。以清晰的图形化界面显示 CPU、内存、磁盘、网络和进程信息,支持键盘导航和自定义设置。

主要功能

  1. 01实时监控 CPU、内存、磁盘和网络资源
  2. 02以图形方式可视化历史数据和趋势
  3. 03通过键盘快速导航和过滤进程

适用场景

  1. 01在开发和生产环境中监控系统性能
  2. 02识别占用资源过多的进程并采取行动
  3. 03长期观察系统资源使用趋势

安装

选择你的系统或包管理器,复制命令到终端运行。

$
brew install btop

安装完成后运行btop --version确认安装成功。

命令示例

常用命令按使用顺序排列。

01
btop

详细介绍

btop++

打包状态

Linux macOS FreeBSD NetBSD OpenBSD 用途 c++23 最新版本 捐赠 赞助 请我喝杯咖啡 btop Linux 持续构建 macOS 持续构建 FreeBSD 持续构建 NetBSD 持续构建 OpenBSD 持续构建

目录

如果您考虑捐赠,请优先考虑捐赠给:

README 配图 README 配图

新闻

2026 年 3 月 22 日

更新了 AI 生成代码的贡献指南:

  • 任何代码由 AI 生成的提交都必须标记为 [AI generated]。

    (当代码是通过直接向大模型发送提示词或通过“注释提示”生成时。)

  • 如果只在“自动补全”模式下使用 AI 建议来生成样板代码或其他重复性代码,则无需标记。

  • 如果未在 PR 中披露 AI 的使用情况,PR 将被关闭;故意试图隐瞒 AI 的使用情况,将导致你的账户被封禁,无法再次参与贡献。

  • 如果 PR 是“氛围编程”生成的,且作者似乎不理解生成的代码,则该 PR 将被拒绝。

2025 年 12 月 4 日

由于 AI 生成或辅助的 PR 数量不断增加,现已在 CONTRIBUTING.md 中添加以下指南:

  • 如果提交中的大部分代码由 AI 生成,则必须标记为 [AI generated]。

  • 如果 PR 是“氛围编程”生成的,且作者似乎不理解生成的代码,则该 PR 将被拒绝。

2024 年 9 月 22 日

Btop 发布 v1.4.0

新增 Intel GPU 支持。请注意,目前仅支持监控 GPU 使用率、功耗和时钟速度。感谢 @bjia56 的贡献。

新增 NetBSD 支持。感谢 @fraggerfox 的贡献。

有关新功能、错误修复和新主题的详细列表,请参阅 CHANGELOG.md 和最新的发行版。

2024 年 1 月 7 日

Btop 发布 v1.3.0

这是一次重大更新,新增 Linux GPU 支持和 OpenBSD 平台支持。特别感谢 @romner-set(GPU 支持)和 @joske(OpenBSD 支持)的贡献。 此外还包含大量错误修复和小幅改动。详细列表和贡献者信息请参阅 CHANGELOG.md 和最新的发行版。

有关 GPU 支持的更多信息,请参阅下方的新闻条目。

2023 年 11 月 25 日

Linux 新增 GPU 监控!

从 git 主分支编译即可试用。

使用 5、6、7 和 0 键显示或隐藏 GPU 监控框。5 = GPU 1,6 = GPU 2,依此类推。

GPU 统计数据和图表也可以显示在“CPU 框”中(信息较少)。详情和配置请参阅 CPU 选项菜单。

请注意,发行页面提供的二进制文件(发布时)和持续构建版本均不会启用 GPU 支持。

由于 GPU 支持依赖于加载动态 GPU 库,因此同时使用静态链接时将无法使用 GPU 支持。

有关如何编译以启用 GPU 监控支持的更多信息,请参阅编译 Linux。

非常感谢 @romner-set,他完成了 GPU 支持实现中的绝大部分工作。

包含版本升级至 1.3 的重大更新即将推出。

2022 年 8 月 28 日

btop4win

btop4win 首次发布,现已可在 https://github.com/aristocratos/btop4win 获取。

更多……
2022 年 1 月 16 日

发布 v1.2.0,新增 FreeBSD 支持。目前尚未提供 FreeBSD 发行版二进制文件。

再次感谢 @joske 在移植工作中的努力!

随着 Linux、macOS 和 FreeBSD 兼容性工作完成,今后的重点将转向 GPU 监控等新功能。

2021 年 11 月 13 日

发布 v1.1.0,新增 macOS 支持。目前 continuous-build-macos 中的二进制文件仅支持 x86。 发行版中包含适用于 x86 和 ARM64(Apple Silicon)的 macOS 二进制文件和安装程序。

非常感谢 @joske,他完成了实现中的绝大部分工作!

##### 2021 年 10 月 30 日

OSX [macOS] 和 FreeBSD 分支由 @joske 发起并主要负责开发,预计将在接下来几周内完成。 OSX [macOS] 分支存在一些内存泄漏,需要解决;两个分支在进程 CPU 使用率计算方面都存在一些问题,还有其他一些小问题需要修复。

如果你想帮忙、测试或修复错误,或者只是想试用这些分支:

macOS / OSX

# Install and use Homebrew or MacPorts package managers for easy dependency installation
brew install coreutils make gcc@11 lowdown
git clone https://github.com/aristocratos/btop.git
cd btop
git checkout OSX
gmake

FreeBSD

sudo pkg install gmake gcc11 coreutils git lowdown
git clone https://github.com/aristocratos/btop.git
cd btop
git checkout freebsd
gmake

请注意,macOS/OSX 推荐使用 GNU make(gmake),但并非必需;而 FreeBSD 则必须使用。

2021 年 10 月 6 日

@joske 已开始 macOS 开发,非常感谢 :) 查看 OSX 分支,了解当前进度。

2021 年 9 月 18 日

btop++ 的 Linux 版本已完成,作为 1.0.0 版本发布。

对于遇到编译问题的用户,我会在每次发布时提供适用于多种架构的静态编译二进制文件。

编译需要 GCC 11。

请在 Issues 页面报告任何错误。

目前的开发计划:

  • 1.1.0 支持 macOS [OSX]
  • 1.2.0 支持 FreeBSD
  • 1.3.0 支持 GPU 监控
  • 1.X.0 其他平台和功能……

目前暂无支持 Windows 的计划,但如果有人愿意接手,我会尽力提供帮助。

2021 年 5 月 5 日

这个项目需要一些时间才能与 bpytop 的功能完全一致,因为所有系统信息收集功能都必须从头编写,不能使用任何外部库。 此外,要完整支持 BSD 和 macOS/OSX,还需要大家通过代码贡献提供帮助。

文档

CHANGELOG.md

CONTRIBUTING.md

CODE_OF_CONDUCT.md

描述

资源监视器,可显示处理器、内存、磁盘、网络和进程的使用情况与统计信息。

bashtop 和 bpytop 的 C++ 版本和后续项目。

功能

  • 易于使用,采用受游戏启发的菜单系统。
  • 全面支持鼠标:所有带高亮按键的按钮均可点击,并且可以在进程列表和菜单框中滚动鼠标滚轮。
  • 快速灵敏的 UI,可使用 UP、DOWN 键选择进程。
  • 提供所选进程的详细统计信息。
  • 可筛选进程。
  • 可轻松切换排序选项。
  • 以树形视图显示进程。
  • 向所选进程发送任意信号。
  • 暂停进程列表。
  • 提供 UI 菜单,用于更改配置文件中的所有选项。
  • 网络使用情况图表可自动缩放。
  • 显示磁盘 IO 活动和速度。
  • 电池电量计
  • 可选择图表符号。
  • 自定义预设
  • 以及更多……

主题

Btop++ 使用与 bpytop 和 bashtop 相同的主题文件(bashtop 主题中缺少一些颜色值)。

请查看 themes 文件夹,了解可用主题。

Btop 会在以下目录中搜索系统主题:

  • ../share/btop/themes(此路径相对于 btop 可执行文件)
  • /usr/local/share/btop/themes
  • /usr/share/btop/themes

第一个存在且非空的目录会被用作系统主题目录。

用户主题目录取决于设置了哪些环境变量:

  • 如果设置了 $XDG_CONFIG_HOME,用户主题目录为 $XDG_CONFIG_HOME/btop/themes
  • 否则,如果设置了 $HOME,用户主题目录为 $HOME/.config/btop/themes
  • 否则,用户主题目录为 ~/.config/btop/themes

make install 命令会将默认主题放在 [$PREFIX or /usr/local]/share/btop/themes。 用户创建的主题应放在用户主题目录中。

使用 --themes-dir 命令行选项指定自定义主题目录。 指定后,此目录的优先级高于默认搜索路径。

欢迎提交新主题。

新增的进程列表暂停和进程跟随功能引入了一些新的主题属性。 这些属性仍需添加到所有现有主题中(默认主题除外)。

进程列表横幅属性:

  • proc_pause_bg:列表暂停时横幅的背景颜色。
  • proc_follow_bg:进程跟随功能启用时横幅的背景颜色。
  • proc_banner_bg:进程跟随功能启用且列表暂停时横幅的背景颜色。
  • proc_banner_fg:横幅的前景(文本)颜色

进程跟随属性:

  • followed_bg:列表中被跟随进程的背景颜色。
  • followed_fg:列表中被跟随进程的前景颜色。

支持与资助

你可以通过 GitHub 赞助此项目。请查看我的赞助者页面,了解相关方式。

也可以通过 PayPal 或 ko-fi 捐赠。

非常感谢任何形式的支持!

前置条件

为获得最佳体验,请在支持以下功能的终端中运行:

  • 24 位真彩色(查看支持真彩色的终端列表)
  • 通过将选项中的 "truecolor" 设为 False,或使用 "-lc/--low-color" 参数,支持将 24 位颜色转换为 256 色,以适配 256 色终端。
  • 检测到真实的 tty 设备时,会启用 16 色 TTY 模式。可使用 "-t/--tty" 参数强制启用。
  • 宽字符(在基于 Web 的终端中有时会有问题)

此外,还需要 UTF8 区域设置和包含以下字符的字体:

  • Unicode 区块“盲文图案” U+2800 - U+28FF(TTY 模式下,或图表类型设为 block 或 tty 时不需要。)
  • Unicode 区块“几何图形” U+25A0 - U+25FF
  • Unicode 区块 "制表符" 和 "区块元素" U+2500 - U+259F
可选依赖项(GPU 监控所需)

Linux 和搭载 Apple Silicon GPU 的 macOS 均支持 GPU 监控。

GPU 监控还需要使用启用了 GPU 支持的 btop 二进制文件(GPU_SUPPORT=true 标志)。

有关如何编译并启用 GPU 支持的更多信息,请参阅 GPU 兼容性部分。

  • NVIDIA

    如果你有 NVIDIA GPU,则必须使用 NVIDIA 官方驱动。经验证,闭源和开源驱动均可正常工作。

    此外,还必须安装 nvidia-ml 动态库,该库应包含在你所用发行版的驱动程序包中。

  • AMD

    如果你有 AMD GPU,则需要 rocm_smi_lib,但你的发行版可能提供也可能不提供该软件包。

  • INTEL

    如果从源代码编译,则需要可用的 C 编译器。

    此外,用户还需要拥有从 SYSFS 读取的权限。

    可以通过 make setcap(推荐)、make setuid,或使用 sudo 或同等方式运行 btop 来设置。

注意(文本渲染问题)
  • 如果图表中的字符显示效果与截图不一致,很可能是系统配置的备用字体不支持盲文字符。

  • 请参阅 Terminess Powerline,这是包含盲文符号的字体示例。

  • 如需了解可能的解决方案,请参阅 issue #100 中 @sgleizes 的评论 链接和 @XenHat 的评论 链接。

  • 如果文本错位,且你使用 Konsole 或 Yakuake,可以尝试关闭“Bi-Directional text rendering”。

  • 字符相互重叠,或文本与边框错位,并非 btop 引起的 bug;这很可能是 fontconfig 或终端问题,导致构成图表的盲文字符无法正确渲染。

  • 如果上述解决方法均无效,请联系你所用终端模拟器的开发者解决这些问题。

截图

显示所选进程详情的主界面

Screenshot 1

TTY 模式下的主界面

Screenshot 2

使用自定义选项的主界面

Screenshot 3

主菜单

Screenshot 3

选项菜单

Screenshot 4

帮助菜单

Screenshot 5

安装

Linux 二进制文件使用 musl 静态编译,可在内核版本 2.6.39 及更高版本上运行

  1. 从最新版本下载 btop-(VERSION)-(ARCH)-(PLATFORM).tbz,并解压到新文件夹

    注意!64 位 x86 系统请使用 x86_64,i486 和 i686 是 32 位!

  2. 安装(在新建的文件夹中)

    • 运行:
    # use "make install PREFIX=/target/dir" to set target, default: /usr/local
    # only use "sudo" when installing to a NON user owned directory
    sudo make install
    
  3. (可选/Intel GPU 和 CPU 功耗监控所必需)为 btop 设置扩展权限或 suid 位

    这样无需使用 sudo 启动即可向任意进程发送信号,还可以避免某些系统上的 /proc 读取权限问题。

    Intel GPU 支持和 CPU 功耗监控需要此设置。

    • 运行:
    # run after make install and use same PREFIX if any was used at install
    sudo make setcap
    
    • 或
    # run after make install and use same PREFIX if any was used at install
    # set SU_USER and SU_GROUP to select user and group, default is root:root
    sudo make setuid
    
  • 卸载

    • 运行:
    sudo make uninstall
    
  • 显示帮助

    make help
    

二进制版本(来自原生操作系统软件仓库)

  • openSUSE
  • Fedora
    sudo dnf install btop
    
  • RHEL/Rocky/AlmaLinux 8+
    sudo dnf install epel-release
    sudo dnf install btop
    
  • FreeBSD
    pkg install btop
    
  • NetBSD
    pkg_add btop
    

通过 Homebrew 安装二进制版本(macOS(x86_64 和 ARM64)/Linux(x86_64))

Linux 编译

至少需要 GCC 14 或 Clang 19。

Makefile 还需要 GNU coreutils 和 sed(现代发行版通常已预装)。

GPU 兼容性

在 Linux x86_64 上,只要安装了正确的驱动和库,Btop++ 开箱即支持 Nvidia 和 AMD GPU,以及 Intel 集成 GPU。

静态链接 glibc(或 musl 等)时,Nvidia 或 AMD GPU 支持将无法使用!

对于 x86_64 Linux,GPU_SUPPORT 标志会自动设为 true。如需手动禁用 GPU 支持,请将该标志设为 false,例如:

make GPU_SUPPORT=false(使用 CMake 时则为 cmake -DBTOP_GPU=false)

  • NVIDIA

    必须使用官方 NVIDIA 驱动。经验证,闭源驱动和开源驱动均可正常工作。

    此外,还必须安装 nvidia-ml 动态库,该库应包含在发行版的驱动软件包中。

  • AMD

    AMDGPU 数据通过 ROCm SMI 库查询,该库可能已打包,也可能没有。如果发行版未提供软件包,btop++ 会通过 RSMI_STATIC=true make 标志静态链接 ROCm SMI。

    此标志要求 ROCm SMI 源代码位于 lib/rocm_smi_lib 中;如果该目录不存在,编译将失败。最新测试版本为 5.6.x,可通过以下命令获取:

    git clone https://github.com/rocm/rocm_smi_lib.git --depth 1 -b rocm-5.6.x lib/rocm_smi_lib
    
### 使用 Make
  1. 安装依赖项(以 Ubuntu 24.04 Noble 为例)

    sudo apt install coreutils sed git build-essential lowdown
    
  2. 克隆仓库

    git clone https://github.com/aristocratos/btop.git
    cd btop
    
  3. 编译

    make
    

    Make 选项:

    标志描述
    VERBOSE=true显示完整的编译器/链接器命令
    STATIC=true进行静态编译
    QUIET=true减少输出信息
    STRIP=true强制剥离调试符号(添加 -s 链接器标志)
    DEBUG=true将 OPTFLAGS 设为 -O0 -g,并启用更详细的调试日志
    ARCH=<architecture>手动设置目标架构
    GPU_SUPPORT=<true|false>启用/禁用 GPU 支持(默认在 X86_64 Linux 上启用)
    RSMI_STATIC=true静态链接用于查询 AMDGPU 的 ROCm SMI 库
    ADDFLAGS=<flags>为编译器和链接器追加标志
    CXX=<compiler>手动设置要使用的编译器

    示例:make ADDFLAGS=-march=native;如果只针对自己的系统进行编译,可能会提升性能。

    注意!如果使用 LDAP Authentication,在 glibc 下进行静态编译时,LDAP 用户的用户名将显示为 UID 编号。

  4. 安装

    sudo make install
    

    追加 PREFIX=/target/dir 以设置目标路径,默认值:/usr/local

    注意!仅在安装到非用户所有的目录时使用 “sudo”。

  5. (可选/Intel GPU 支持和 CPU 功耗所必需)为 btop 设置扩展功能或 suid 位

    无需使用 sudo,即可向任何进程发送信号,并避免某些系统上的 /proc 读取权限问题。

    Intel GPU 监控和 CPU 功耗监控也需要此设置。

    在 make install 后运行;如果安装时使用了 PREFIX,请使用相同的 PREFIX。

    sudo make setcap
    

    或者

    设置 SU_USER 和 SU_GROUP 来选择用户和组,默认值为 root 和 root

    sudo make setuid
    
  • 卸载

    sudo make uninstall
    
  • 从源代码目录中移除所有目标文件

    make clean
    
  • 从源代码目录中移除所有目标文件、二进制文件和创建的目录

    make distclean
    
  • 显示帮助

    make help
    
### 使用 CMake(由社区维护)
  1. 安装构建依赖项

    需要 Clang / GCC、CMake、Ninja、Lowdown 和 Git

    例如,在 Debian Bookworm 上:

    sudo apt install cmake git g++ ninja-build lowdown
    
  2. 克隆仓库

    git clone https://github.com/aristocratos/btop.git && cd btop
    
  3. 编译

    # Configure
    cmake -B build -G Ninja
    # Build
    cmake --build build
    

    这将自动构建 btop 的发布版本。

    配置步骤中可传入的一些实用选项:

    配置标志说明
    -DBTOP_STATIC=<ON|OFF>启用静态链接(默认关闭)
    -DBTOP_LTO=<ON|OFF>启用链接时优化(默认开启)
    -DBTOP_GPU=<ON|OFF>启用 GPU 支持(默认开启)
    -DBTOP_RSMI_STATIC=<ON|OFF>静态构建并链接 ROCm SMI 库(默认关闭)
    -DCMAKE_INSTALL_PREFIX=<path>安装前缀(默认为 '/usr/local')

    若要强制使用其他编译器,请运行 CXX=<compiler> cmake -B build -G Ninja

  4. 安装

    cmake --install build
    

    可能需要 root 权限

  5. 卸载

    CMake 默认不会生成卸载目标。若要删除已安装的文件,请运行

    cat build/install_manifest.txt | xargs rm -irv
    
  6. 清理构建目录

    cmake --build build -t clean
    

macOS OSX 编译

至少需要 GCC 14 或 Clang 19。

Makefile 还需要 GNU coreutils 和 sed。

使用 Homebrew 或 MacPorts 包管理器可轻松安装依赖项

### 使用 Make
  1. 安装依赖项(以 Homebrew 为例)

    brew install coreutils make gcc@15 lowdown
    
  2. 克隆仓库

    git clone https://github.com/aristocratos/btop.git
    cd btop
    
  3. 编译

    gmake
    

    make 选项:

    标志说明
    VERBOSE=true显示完整的编译器/链接器命令
    STATIC=true进行静态编译(仅使用 libgcc 和 libstdc++)
    QUIET=true减少输出详细程度
    STRIP=true强制剥离调试符号(添加 -s 链接器标志)
    DEBUG=true将 OPTFLAGS 设为 -O0 -g,并启用更详细的调试日志
    GPU_SUPPORT=<true|false>启用/禁用 GPU 支持(在 macOS 上默认启用)
    ARCH=<architecture>手动设置目标架构
    ADDFLAGS=<flags>为编译器和链接器追加标志
    CXX=<compiler>手动设置要使用的编译器

    示例:gmake ADDFLAGS=-march=native 在仅针对自己的系统进行编译时,可能会提升性能。

  4. 安装

    sudo gmake install
    

    添加 PREFIX=/target/dir 以设置目标路径,默认为:/usr/local

    注意!仅在安装到非当前用户拥有的目录时使用 "sudo"。

  5. (推荐)设置 suid 位,使 btop 始终以 root(或其他用户)身份运行

    sudo gmake setuid
    

    无需使用 sudo,即可查看非当前用户拥有的进程信息,并向任何进程发送信号。

    在 make install 后运行;如果安装时使用了 PREFIX,请使用相同的 PREFIX。

    设置 SU_USER 和 SU_GROUP 以选择用户和组,默认值为 root 和 wheel

  • 卸载

    sudo gmake uninstall
    
  • 从源代码目录中删除所有目标文件

    gmake clean
    
  • 从源代码目录中删除所有目标文件、二进制文件和创建的目录

    gmake distclean
    
  • 显示帮助

    gmake help
    
使用 CMake(由社区维护)
  1. 安装构建依赖项

    需要 Clang、CMake、Ninja、Lowdown 和 Git

    brew update --quiet
    brew install cmake git llvm ninja lowdown
    
  2. 克隆仓库

    git clone https://github.com/aristocratos/btop.git && cd btop
    
  3. 编译

    # Configure
    export LLVM_PREFIX="$(brew --prefix llvm)"
    export CXX="$LLVM_PREFIX/bin/clang++"
    export CPPFLAGS="-I$LLVM_PREFIX/include"
    export LDFLAGS="-L$LLVM_PREFIX/lib -L$LLVM_PREFIX/lib/c++ -Wl,-rpath,$LLVM_PREFIX/lib/c++ -fuse-ld=$LLVM_PREFIX/bin/ld64.lld"
    cmake -B build -G Ninja
    # Build
    cmake --build build
    

    这将自动构建 btop 的发行版。

    配置步骤中可传入的一些实用选项:

    配置标志说明
    -DBTOP_LTO=<ON|OFF>启用链接时优化(默认开启)
    -DBTOP_GPU=<ON|OFF>启用 GPU 支持(默认开启)
    -DCMAKE_INSTALL_PREFIX=<path>安装前缀(默认为 '/usr/local')

    要指定特定编译器,请运行 CXX=<compiler> cmake -B build -G Ninja

  4. 安装

    cmake --install build
    

    可能需要 root 权限

  5. 卸载

    CMake 默认不会生成卸载目标。要删除已安装的文件,请运行

    cat build/install_manifest.txt | xargs rm -irv
    
  6. 清理构建目录

    cmake --build build -t clean
    

FreeBSD 编译

需要 Clang 19(默认)或 GCC 14 及更高版本。

请注意,在 FreeBSD 上编译需要 GNU make(gmake)。

### 使用 gmake
  1. 安装依赖项

    sudo pkg install gmake coreutils git lowdown
    
  2. 克隆仓库

    git clone https://github.com/aristocratos/btop.git
    cd btop
    
  3. 编译

    gmake
    

    make 的选项:

    标志说明
    VERBOSE=true显示完整的编译器/链接器命令
    STATIC=true静态编译(仅使用 libgcc 和 libstdc++)
    QUIET=true减少输出冗余
    STRIP=true强制剥离调试符号(添加 -s 链接器标志)
    DEBUG=true将 OPTFLAGS 设为 -O0 -g,并启用更详细的调试日志
    ARCH=<architecture>手动设置目标架构
    ADDFLAGS=<flags>为编译器和链接器追加标志
    CXX=<compiler>手动设置要使用的编译器

    例如:gmake ADDFLAGS=-march=native 在仅针对自己的系统编译时,可能会提升性能。

  4. 安装

    sudo gmake install
    

    添加 PREFIX=/target/dir 以设置目标目录,默认为:/usr/local

    注意!仅在安装到非用户所有的目录时使用 “sudo”。

  5. (推荐)设置 suid 位,使 btop 始终以 root(或其他用户)身份运行

    sudo gmake setuid
    

    无需使用 sudo,即可查看非用户所有进程的信息,并向任何进程发送信号。

    在 make install 后运行;如果安装时使用了 PREFIX,请使用相同的 PREFIX。

    设置 SU_USER 和 SU_GROUP 来选择用户和组,默认值分别为 root 和 wheel

  • 卸载

    sudo gmake uninstall
    
  • 从源代码目录中移除所有目标文件

    gmake clean
    
  • 从源代码目录中移除所有目标文件、二进制文件和已创建的目录

    gmake distclean
    
  • 显示帮助

    gmake help
    
使用 CMake(由社区维护)
  1. 安装构建依赖项

    需要 Clang / GCC、CMake、Ninja、Lowdown 和 Git

    pkg install cmake ninja lowdown
    
  2. 克隆仓库

    git clone https://github.com/aristocratos/btop.git && cd btop
    
  3. 编译

    # Configure
    cmake -B build -G Ninja
    # Build
    cmake --build build
    

    这将自动构建 btop 的发行版。

    配置步骤中可传入的一些实用选项:

    配置标志说明
    -DBTOP_STATIC=<ON|OFF>启用静态链接(默认关闭)
    -DBTOP_LTO=<ON|OFF>启用链接时优化(默认开启)
    -DCMAKE_INSTALL_PREFIX=<path>安装前缀(默认为“/usr/local”)

    注意: 静态链接无法与 GCC 配合使用。

    若要强制使用其他编译器,请运行 CXX=<compiler> cmake -B build -G Ninja

  4. 安装

    cmake --install build
    

    可能需要 root 权限

  5. 卸载

    CMake 默认不会生成卸载目标。要移除已安装的文件,请运行

    cat build/install_manifest.txt | xargs rm -irv
    
  6. 清理构建目录

    cmake --build build -t clean
    

NetBSD 编译

至少需要 GCC 14。

请注意,在 NetBSD 上编译需要 GNU make(gmake)。

### 使用 gmake
  1. 安装依赖项

    /usr/sbin/pkg_add pkgin
    pkgin install -y coregutils gcc14 git gmake
    
  2. 克隆仓库

    git clone https://github.com/aristocratos/btop.git
    cd btop
    
  3. 编译

    CXX=/usr/pkg/gcc14/bin/g++ gmake CXXFLAGS="-DNDEBUG"
    

    make 的选项:

    标志说明
    VERBOSE=true显示完整的编译器/链接器命令
    STATIC=true进行静态编译(仅使用 libgcc 和 libstdc++)
    QUIET=true减少输出信息
    STRIP=true强制剥离调试符号(添加 -s 链接器标志)
    DEBUG=true将 OPTFLAGS 设为 -O0 -g,并启用更详细的调试日志
    ARCH=<architecture>手动设置目标架构
    ADDFLAGS=<flags>为编译器和链接器追加标志
    CXX=<compiler>手动设置要使用的编译器

    示例:gmake ADDFLAGS=-march=native 可能会提升性能(仅针对自己的系统进行编译时)。

  4. 安装

    sudo gmake install
    

    追加 PREFIX=/target/dir 以设置目标路径,默认值:/usr/local

    注意!仅在安装到非用户拥有的目录时使用 “sudo”。

  5. (推荐)设置 suid 位,使 btop 始终以 root(或其他用户)身份运行

    sudo gmake setuid
    

    无需使用 sudo,即可查看非用户拥有的进程信息,并向任何进程发送信号。

    在 make install 后运行;如果安装时使用了 PREFIX,请使用相同的值。

    设置 SU_USER 和 SU_GROUP 以选择用户和组,默认值分别为 root 和 wheel

  • 卸载

    sudo gmake uninstall
    
  • 从源代码目录中移除所有目标文件

    gmake clean
    
  • 从源代码目录中移除所有目标文件、二进制文件和已创建的目录

    gmake distclean
    
  • 显示帮助

    gmake help
    
使用 CMake(由社区维护)
  1. 安装构建依赖项

    需要 GCC、CMake、Ninja 和 Git

    /usr/sbin/pkg_add pkgin
    pkgin install cmake ninja-build gcc14 git
    
  2. 克隆仓库

    git clone https://github.com/aristocratos/btop.git && cd btop
    
  3. 编译

    # Configure
    CXX="/usr/pkg/gcc14/bin/g++" cmake -B build -G Ninja
    # Build
    cmake --build build
    

    这将自动构建 btop 的发布版本。

    配置步骤中可传入的一些实用选项:

    配置标志说明
    -DBTOP_LTO=<ON|OFF>启用链接时优化(默认开启)
    -DCMAKE_INSTALL_PREFIX=<path>安装前缀(默认为 '/usr/local')

    若要强制使用其他编译器,请运行 CXX=<compiler> cmake -B build -G Ninja

  4. 安装

    cmake --install build
    

    可能需要 root 权限

  5. 卸载

    CMake 默认不会生成卸载目标。若要移除已安装的文件,请运行

    cat build/install_manifest.txt | xargs rm -irv
    
  6. 清理构建目录

    cmake --build build -t clean
    

在 OpenBSD 上编译

请注意,在 OpenBSD 上编译需要 GNU make(gmake)。

### 使用 gmake
  1. 安装依赖项

    pkg_add coreutils git gmake lowdown
    
  2. 克隆仓库

    git clone https://github.com/aristocratos/btop.git
    cd btop
    
  3. 编译

    gmake
    

    make 选项:

    标志说明
    VERBOSE=true显示完整的编译器/链接器命令
    STATIC=true进行静态编译(仅使用 libgcc 和 libstdc++)
    QUIET=true减少输出详细程度
    STRIP=true强制剥离调试符号(添加 -s 链接器标志)
    DEBUG=true将 OPTFLAGS 设为 -O0 -g,并启用更详细的调试日志
    ARCH=<architecture>手动设置目标架构
    ADDFLAGS=<flags>将标志附加到编译器和链接器
    CXX=<compiler>手动设置要使用的编译器

    示例:gmake ADDFLAGS=-march=native 在仅针对自己的系统编译时可能会提升性能。

  4. 安装

    sudo gmake install
    

    添加 PREFIX=/target/dir 以设置目标目录,默认值:/usr/local

    注意!仅在安装到非用户所有的目录时使用“sudo”。

  5. (推荐)设置 suid 位,使 btop 始终以 root(或其他用户)身份运行

    sudo gmake setuid
    

    无需使用 sudo,即可查看非用户所有进程的信息,并向任何进程发送信号。

    在 make install 后运行;如果安装时使用了 PREFIX,请使用相同的 PREFIX。

    设置 SU_USER 和 SU_GROUP 以选择用户和组,默认值分别为 root 和 wheel

  • 卸载

    sudo gmake uninstall
    
  • 移除源目录中的所有目标文件

    gmake clean
    
  • 移除源目录中的所有目标文件、二进制文件和已创建的目录

    gmake distclean
    
  • 显示帮助

    gmake help
    
使用 CMake(由社区维护)
  1. 安装构建依赖项

    需要 GCC、CMake、Ninja、Lowdown 和 Git

    注意: OpenBSD 7.4 附带的 LLVM libc++ 版本过旧,无法编译 btop。

    pkg_add cmake git ninja lowdown
    
  2. 克隆仓库

    git clone https://github.com/aristocratos/btop.git && cd btop
    
  3. 编译

    # Configure
    cmake -B build -G Ninja
    # Build
    cmake --build build
    

    这将自动构建 btop 的发布版本。

    配置步骤可传入以下一些实用选项:

    配置标志说明
    -DBTOP_LTO=<ON|OFF>启用链接时优化(默认开启)
    -DCMAKE_INSTALL_PREFIX=<path>安装前缀(默认为“/usr/local”)

    若要强制使用其他编译器,请运行 CXX=<compiler> cmake -B build -G Ninja

  4. 安装

    cmake --install build
    

    可能需要 root 权限

  5. 卸载

    CMake 默认不会生成卸载目标。若要移除已安装的文件,请运行

    cat build/install_manifest.txt | xargs rm -irv
    
  6. 清理构建目录

    cmake --build build -t clean
    

测试

测试需要 CMake。默认会构建测试,可使用 ctest --test-dir <build> 运行。

如果要禁用测试构建,请在配置步骤中传入 -DBUILD_TESTING=OFF。

安装 snap

btop

注意:现在提供两个 Snap 包:btop 和 btop-desktop。桌面版体积大得多,并包含桌面入口,以便点击即可启动 btop。
  • 安装 Snap 包

    sudo snap install btop
    or
    sudo snap install btop-desktop
    
  • 从 edge 通道安装最新的 Snap 包

    sudo snap install btop --edge
    or
    sudo snap install btop-desktop --edge
    
  • 连接接口

    sudo snap connect btop:removable-media
    or
    sudo snap connect btop-desktop:removable-media
    

可配置性

所有选项都可以在 UI 中更改。 配置文件和日志文件存储在 $XDG_CONFIG_HOME/btop 或 $HOME/.config/btop 文件夹中

btop.conf:(未找到时自动生成)
#? Config file for btop v.1.4.5

#* 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 whitespace " " 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,g,G" keys for directional control in lists.
#* Conflicting keys for h:"help" and k:"kill" is accessible while holding shift.
vim_keys = false

#* Rounded corners on boxes, is ignored if TTY mode is ON.
rounded_corners = true

#* Use terminal synchronized output sequences to reduce flickering on supported terminals.
terminal_sync = true

#* Default symbols to use for graph creation, "braille", "block" or "tty".
#* "braille" offers the highest resolution but might not be included in all fonts.
#* "block" has half the resolution of braille but uses more common characters.
#* "tty" uses only 3 different symbols but will work with most fonts and should work in a real TTY.
#* Note that "tty" only has half the horizontal resolution of the other two, so will show a shorter historical view.
graph_symbol = "braille"

# Graph symbol to use for graphs in cpu box, "default", "braille", "block" or "tty".
graph_symbol_cpu = "default"

# Graph symbol to use for graphs in cpu box, "default", "braille", "block" or "tty".
graph_symbol_mem = "default"

# Graph symbol to use for graphs in cpu box, "default", "braille", "block" or "tty".
graph_symbol_net = "default"

# Graph symbol to use for graphs in cpu box, "default", "braille", "block" or "tty".
graph_symbol_proc = "default"

#* Manually set which boxes to show. Available values are "cpu mem net proc" and "gpu0" through "gpu5", separate values with whitespace.
shown_boxes = "cpu mem net proc"

#* Update time in milliseconds, recommended 2000 ms or above for better sample times for graphs.
update_ms = 2000

#* Processes sorting, "pid" "program" "arguments" "threads" "user" "memory" "cpu lazy" "cpu direct",
#* "cpu lazy" sorts top process over time (easier to follow), "cpu direct" updates top process directly.
proc_sorting = "cpu lazy"

#* Reverse sorting order, True or False.
proc_reversed = false

#* Show processes as a tree.
proc_tree = false

#* Use the cpu graph colors in the process list.
proc_colors = true

#* Use a darkening gradient in the process list.
proc_gradient = true

#* If process cpu usage should be of the core it's running on or usage of the total available cpu power.
proc_per_core = false

#* Show process memory as bytes instead of percent.
proc_mem_bytes = true

#* Show cpu graph for each process.
proc_cpu_graphs = true

#* Use /proc/[pid]/smaps for memory information in the process info box (very slow but more accurate)
proc_info_smaps = false

#* Show proc box on left side of screen instead of right.
proc_left = false

#* (Linux) Filter processes tied to the Linux kernel(similar behavior to htop).
proc_filter_kernel = false

#* Should the process list follow the selected process when detailed view is open.
proc_follow_detailed = true

#* In tree-view, always accumulate child process resources in the parent process.
proc_aggregate = false

#* In tree-view, auto-collapse processes with this many or more direct children when
#* entering tree mode. 0 to disable. Useful for collapsing multi-process apps like browsers.
proc_tree_auto_collapse = 0

#* Should cpu and memory usage display be preserved for dead processes when paused.
keep_dead_proc_usage = false

#* Sets the CPU stat shown in upper half of the CPU graph, "total" is always available.
#* Select from a list of detected attributes from the options menu.
cpu_graph_upper = "Auto"

#* Sets the CPU stat shown in lower half of the CPU graph, "total" is always available.
#* Select from a list of detected attributes from the options menu.
cpu_graph_lower = "Auto"

#* Toggles if the lower CPU graph should be inverted.
cpu_invert_lower = true

#* Set to True to completely disable the lower CPU graph.
cpu_single_graph = false

#* Show cpu box at bottom of screen instead of top.
cpu_bottom = false

#* Shows the system uptime in the CPU box.
show_uptime = true

#* Shows the CPU package current power consumption in watts. Requires running `make setcap` or `make setuid` or running with sudo.
show_cpu_watts = true

#* Show cpu temperature.
check_temp = true

#* Which sensor to use for cpu temperature, use options menu to select from list of available sensors.
cpu_sensor = "Auto"

#* Show temperatures for cpu cores also if check_temp is True and sensors has been found.
show_coretemp = true

#* Set a custom mapping between core and coretemp, can be needed on certain cpus to get correct temperature for correct core.
#* Use lm-sensors or similar to see which cores are reporting temperatures on your machine.
#* Format "x:y" x=core with wrong temp, y=core with correct temp, use space as separator between multiple entries.
#* Example: "4:0 5:1 6:3"
cpu_core_map = ""

#* Which temperature scale to use, available values: "celsius", "fahrenheit", "kelvin" and "rankine".
temp_scale = "celsius"

#* Use base 10 for bits/bytes sizes, KB = 1000 instead of KiB = 1024.
base_10_sizes = false

#* Show CPU frequency.
show_cpu_freq = true

#* How to calculate CPU frequency, available values: "first", "range", "lowest", "highest" and "average".
freq_mode = "first"

#* Draw a clock at top of screen, formatting according to strftime, empty string to disable.
#* Special formatting: /host = hostname | /user = username | /uptime = system uptime
clock_format = "%X"

#* Update main ui in background when menus are showing, set this to false if the menus is flickering too much for comfort.
background_update = true

#* Custom cpu model name, empty string to disable.
custom_cpu_name = ""

#* Optional filter for shown disks, should be full path of a mountpoint, separate multiple values with whitespace " ".
#* Only disks matching the filter will be shown. Prepend exclude= to only show disks not matching the filter. Examples: disks_filter="/boot /home/user", disks_filter="exclude=/boot /home/user"
disks_filter = ""

#* Show graphs instead of meters for memory values.
mem_graphs = true

#* Show mem box below net box instead of above.
mem_below_net = false

#* Count ZFS ARC in cached and available memory.
zfs_arc_cached = true

#* If swap memory should be shown in memory box.
show_swap = true

#* Show swap as a disk, ignores show_swap value above, inserts itself after first disk.
swap_disk = true

#* If mem box should be split to also show disks info.
show_disks = true

#* Filter out non physical disks. Set this to False to include network disks, RAM disks and similar.
only_physical = true

#* Read disks list from /etc/fstab. This also disables only_physical.
use_fstab = true

#* Setting this to True will hide all datasets, and only show ZFS pools. (IO stats will be calculated per-pool)
zfs_hide_datasets = false

#* Set to true to show available disk space for privileged users.
disk_free_priv = false

#* Toggles if io activity % (disk busy time) should be shown in regular disk usage view.
show_io_stat = true

#* Toggles io mode for disks, showing big graphs for disk read/write speeds.
io_mode = false

#* Set to True to show combined read/write io graphs in io mode.
io_graph_combined = false

#* Set the top speed for the io graphs in MiB/s (100 by default), use format "mountpoint:speed" separate disks with whitespace " ".
#* Example: "/mnt/media:100 /:20 /boot:1".
io_graph_speeds = ""

#* Set fixed values for network graphs in Mebibits. Is only used if net_auto is also set to False.
net_download = 100

net_upload = 100

#* Use network graphs auto rescaling mode, ignores any values set above and rescales down to 10 Kibibytes at the lowest.
net_auto = true

#* Sync the auto scaling for download and upload to whichever currently has the highest scale.
net_sync = true

#* Starts with the Network Interface specified here.
net_iface = ""

#* "True" shows bitrates in base 10 (Kbps, Mbps). "False" shows bitrates in binary sizes (Kibps, Mibps, etc.). "Auto" uses base_10_sizes.
base_10_bitrate = "Auto"

#* Show battery stats in top right if battery is present.
show_battery = true

#* Which battery to use if multiple are present. "Auto" for auto detection.
selected_battery = "Auto"

#* Show power stats of battery next to charge indicator.
show_battery_watts = true

#* Set loglevel for "~/.local/state/btop.log" levels are: "ERROR" "WARNING" "INFO" "DEBUG".
#* The level set includes all lower levels, i.e. "DEBUG" will show all logging info.
log_level = "WARNING"
命令行选项
Usage: btop [OPTIONS]

Options:
  -c, --config <file>     Path to a config file
  -d, --debug             Start in debug mode with additional logs and metrics
  -f, --filter <filter>   Set an initial process filter
      --force-utf         Override automatic UTF locale detection
  -l, --low-color         Disable true color, 256 colors only
  -p, --preset <id>       Start with a preset (0-9)
  -t, --tty               Force tty mode with ANSI graph symbols and 16 colors only
      --no-tty            Force disable tty mode
  -u, --update <ms>       Set an initial update rate in milliseconds
      --default-config    Print default config to standard output
  -h, --help              Show this help message and exit
  -V, --version           Show a version message and exit (more with --version)

许可证

Apache License 2.0

评论

支持 Markdown