How to Force Htop to Save Configuration Changes Immediately
The htop command-line utility is a powerful, interactive
process manager for Linux, but users often find that custom
settings—such as altered color schemes, hidden threads, or rearranged
columns—revert to default after closing the application. This article
provides a straightforward guide on how to force htop to
save its configuration immediately, explains the manual save mechanics
within the interface, and details how to directly edit the underlying
configuration file.
Saving Configuration Changes Directly Within Htop
By default, htop is designed to save its configuration
automatically when you exit the program cleanly using the designated
exit commands. However, if your terminal session crashes, freezes, or
you force-close the window, your modifications will be lost.
To ensure your settings are written to disk immediately without risking data loss, use the built-in setup menu:
- Open
htopin your terminal. - Press F2 (or S on some configurations) to enter the Setup menu.
- Make your desired changes (e.g., adding meters, changing display options, or adjusting colors).
- Navigate back to the main screen by pressing F10 or Esc.
- To explicitly trigger an immediate save and exit cleanly, press F10 or q from the main dashboard.
Note: Avoid closing the terminal window or pressing Ctrl + C to exit
htop. Abruptly killing the process prevents the tool from executing its write-to-disk sequence, causing all recent changes to be discarded.
Verifying and Editing the Htop Configuration File
If htop still refuses to preserve your settings, the
issue usually stems from file permissions or a missing directory
structure. htop stores its configuration in a specific path
relative to the user’s home directory.
The standard location for the configuration file is:
~/.config/htop/htoprc
Step-by-Step Troubleshooting
If your changes are not updating, verify the environment using the following steps:
- Check Directory Existence: Ensure the configuration
directory exists. You can create it manually by running:
mkdir -p ~/.config/htop - Verify File Permissions: Ensure your user account
has read and write permissions for the file. Fix permissions using:
chmod 644 ~/.config/htop/htoprc - Manual Editing: You can bypass the interface
entirely and modify settings directly by opening the file in a text
editor like
nanoorvim:nano ~/.config/htop/htoprc
When you edit and save the htoprc file directly in a
text editor, the changes take effect the exact next time you launch
htop.