如何设置 htop 的默认设置?

MrD*_*Duk 59 ssh display-settings htop

有时,我需要检查整个数据中心内多台机器上的资源以获取整合建议等。我更喜欢 htop,主要是因为交互感觉和显示。

有没有办法将一些设置默认为我的 htop 设置?例如,我想始终展示的一件事是平均 CPU 负载。

重要说明:在特定的盒子上设置它是不可行的 - 我正在寻找一种方法来在每次我 ssh 进入盒子时动态设置它。

这可能吗?

gol*_*cks 64

htop有一个设置屏幕,通过 访问F2,允许您自定义显示的顶部,包括添加或删除“平均负载”字段并设置其样式(文本、条形等)。

这些似乎是自动保存在 中$HOME/.config/htop/htoprc,它警告:

# Beware! This file is rewritten by htop when settings are changed in the interface.
# The parser is also very primitive, and not human-friendly.
Run Code Online (Sandbox Code Playgroud)

即,编辑该内容的风险自负。但是,您应该能够将它从一个系统转移到另一个系统(版本差异有时可能会导致一些问题)。

你也可以设置一个配置,退出,然后复制文件,这样你就可以通过交换/符号链接任何一个与htoprc.

  • 另外,请注意,如果您失去了对 htoprc 的权限,例如以 root/sudo 的身份意外触摸它,htop 将无法更新此文件并且无法静默地保存您的更改。 (2认同)

小智 49

最简单的方法是使用程序中的设置,然后使用F10而不是CTRL+保存并退出程序C。下次您可以按照自己喜欢的方式关闭程序。

  • TL;DR:用 F10 退出,而不是 CTRL-C。 (17认同)
  • 要取消 F10 在 Ubuntu 中打开终端窗口的文件菜单的绑定,请在终端窗口中:编辑 > 首选项 > 常规:取消选中“启用菜单加速键(默认为 F10)” (3认同)

Ste*_*fan 9

重置配置文件中的设置

这是 Ubuntu 18.04 系统上 htop 的默认设置。替换文件的内容$HOME/.config/htop/htoprc就可以了。先做好备份。

# Beware! This file is rewritten by htop when settings are changed in the interface.
# # The parser is also very primitive, and not human-friendly.
fields=0 48 17 18 38 39 40 2 46 47 49 1 
sort_key=1
sort_direction=1
hide_threads=0
hide_kernel_threads=1
hide_userland_threads=0
shadow_other_users=0
show_thread_names=0
show_program_path=1
highlight_base_name=0
highlight_megabytes=1
highlight_threads=1
tree_view=0
header_margin=1
detailed_cpu_time=0
cpu_count_from_zero=0
update_process_names=0
account_guest_in_cpu_meter=0
color_scheme=0
delay=15
left_meters=LeftCPUs Memory Swap 
left_meter_modes=1 1 1 
right_meters=RightCPUs Tasks LoadAverage Uptime 
right_meter_modes=1 2 2 2 
Run Code Online (Sandbox Code Playgroud)