related to this question, I want to inspect a command listed in htop, but the command is very long. Therefore the suggested anwer to select text while holding shift does not work as it does not select somthing that overflows to the right of the screen. Is there any help provided by htop to extract the selected line somehow?

  • 1
    You want to take a note of the pid in htop, then grep for it using ps aux | grep <pid> – djsmiley2k Jun 14 at 15:01
  • Read this answer; note /proc/$pid/cmdline. – Kamil Maciorowski Jun 14 at 16:42

If the command trails off-screen then I'm not aware of a way to copy that text using the mouse, even with using shift. However, you could try:

Optimizing your htop display to reveal the command(s)

Option 1: Within htop, hit F2(if you're on a laptop, that may need to be function+F2), you'll be in the setup menu. Use the arrow keys to scroll down to Columns then hit right to move over to the columns in view. If not all of these columns are useful to you, you can remove some of them with F9(again, that may be function+F9). You can exit back to regular view with ESC and you should see more if not all of the command(s).

Option 2: Within that same setup menu(F2), go to Display options and uncheck the Show program path option with the Enter key, then hit ESC to exit. This may further reduce the size of the process so it is rendered inspect-able. Once you get the command, if you need the full path, you can just run which <command> in the terminal.


Important Note: If you make changes to your htop setup, you can discard them by quitting the program with CTRL+C. If you want to save those changes, quit the program with F10 or q (See here for more detail).

Speculation: Depending on what you want to achieve by inspecting that command, you may be able to achieve it right from htop, which allows you to kill a program(highlight and press F9), change its Niceness(highlight and press F7 to decrease or F8 to increase), and lots of other stuff. See here and here for more examples.

Your Answer

 
discard

By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.

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