Normally in putty you can just select text to copy it, but I can't seem to select text with my mouse in htop.

Of course there's no right click menu to copy, ctrl+c doesn't work, and I didn't see any copy command in the help menu.

Is it possible to copy text in htop?

  • You can select and copy text in top, though you have to be quick before the display changes. I don't know what terminal handling is in htop, but as you observe it seems to preclude selecting and therefore copying. I tried Ctrl-z and reset the terminal, but this didn't help when I restarted the task with fg. So at the moment I conclude that the answer to your question is "no". I am not sure why you want to copy text, but screen capture ought to work as a means to save an instantaneous state. – AFH Sep 10 '14 at 22:01

In my experience, holding Shift lets you select text in programs that have mouse support (of which htop is one, I assume).

  • 5
    It is "alt" under mac – Romain Jouin Jan 2 '17 at 11:17
  • 3
    One caveat, it can only copy visible text. It would still be useful to have a way to copy the command line from htop when it is much longer than the terminal width. – P-Gn Nov 16 '18 at 14:26

One approach to copy long lines from htop is the following:

step 1. Change the font size of your terminal to something very small (say 6pt).

step 2. Run htop and maximize window

step 3. Run your processes, switch to htop window and carefully do Ctrl + Shift + A to select everything, then release A and hit C (without releasing Ctrl + Shift). It might take some time to be able to do it (some of the times you might kill htop accidentally).

step 4. Open gedit or another text editor and Ctrl + V if the editor is a GUI or hit Ctrl + Shift + V if the editor opened on the terminal (for example nano).

  • magic operation : ) – yurenchen Mar 19 '20 at 17:56

If it's a linux server I'd just use the ps -ef command and pipe it to grep. For instance if you wanted to check on a rsync command you'd do this:

ps -ef | grep rsync

And that would spit out any process with the word rsync in it. Though it always will include the grep search as well. To exclude that just run:

ps -ef | grep rsync | grep -v grep

This will exclude grep itself from the search results.

Remember, htop is great software, but it's not the best for grabbing really long strings of text. In that case use ps -ef

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.