在 Ubuntu(以及大多数 Linux 发行版)里,getconf 是一个标准命令行工具,通常已经随系统自带,不需要额外安装。
一般位于:
/usr/bin/getconf
你可以确认一下:
which getconf
# 或
type getconf
极少情况下(比如最小化容器镜像)可能没有,可以安装:
sudo apt update
sudo apt install libc-bin
getconf 属于 libc-bin 包。
getconf LONG_BIT # 查看系统是 32 位还是 64 位
getconf _NPROCESSORS_ONLN # 查看 CPU 核心数
getconf PAGE_SIZE # 查看内存页大小
如果你是想在脚本里使用或者在容器/特定 Ubuntu 版本里找不到,可以告诉我具体环境,我帮你进一步排查。