Ubuntu 16.4服务器环境下如何在htop中隐藏命令?
Hey there! I’ve worked with Ubuntu 16.04 servers and htop quite a bit, so I know exactly how to tackle your need to hide certain commands from the htop view. Let’s break down two straightforward methods—one for temporary use, and one for permanent setup.
Temporary Command Hiding (Single Session)
If you just need to hide commands for your current htop session (it resets when you close htop), follow these steps:
- Launch htop as usual with
htopin your terminal. - Press the F4 key (this activates the Filter function).
- Type in the exact command name or a keyword from the command you want to hide. For example, if you want to hide all
nginxprocesses, just typenginx. - Press Enter—you’ll immediately see all matching processes disappear from the list.
- To revert this and show all processes again, press F4 once more and clear the filter text.
Permanent Command Hiding (Persists Across Sessions)
If you want those commands to stay hidden every time you open htop, you’ll need to edit htop’s configuration file:
- First, make sure htop has generated its config file by running
htoponce and then exiting it. - Open the config file with your favorite editor—nano is easy for beginners:
nano ~/.config/htop/htoprc - Look for a line starting with
hide_processes=(if it doesn’t exist, add it at the end of the file). - Add the command names you want to hide, separated by commas. For example:
hide_processes=nginx,cron,apache2 - Save the file (in nano, press Ctrl+O, then Enter, then Ctrl+X to exit).
- Restart htop, and the specified commands will be hidden automatically every time you launch it.
Quick Note
If you’re trying to hide processes shown in your example screenshot, just replace the command names in the examples above with the exact command strings from your screenshot—htop will match them exactly (or partially if you use a keyword, but exact names are more reliable).
内容的提问来源于stack exchange,提问作者total min

