Refor Blog

Linux 编译安装 htop

发布日期:

将 htop 安装到独立目录 /opt/build/htop,与系统自带的 htop 共存,无需卸载。

环境

  • Debian(适用于 Ubuntu)

步骤

1. 安装编译依赖

sudo apt install libncursesw5-dev autotools-dev autoconf automake build-essential libsensors-dev

libsensors-dev--enable-sensors 选项(启用传感器温度显示)所需的依赖。

2. 下载源码

git clone https://github.com/htop-dev/htop.git
cd htop

3. 编译并安装

./autogen.sh
./configure --prefix=/opt/build/htop --enable-sensors
make
sudo make install

4. 配置环境变量

编辑 ~/.bashrc,添加:

export PATH="/opt/build/htop/bin:$PATH"

重新打开终端后,htop 命令将优先使用编译的新版本。