Every running process keeps its full command line in a file at /proc/<pid>/cmdline . htop's command column is that file, read and cleaned up. The arguments are stored separated by null bytes, so cat smears them together:
$ cat /proc/12503/cmdline sleep1000
Enter fullscreen mode
Exit fullscreen mode
Run it through tr '\0' ' ' or strings and you get sleep 1000 back. htop does the same substitution before it draws the row.
That is how htop, top and ps work. None of them has a privileged channel into the kernel. They read /proc , a pseudo-filesystem the kernel presents as ordinary files you can ls and cd through. Everything the kernel exposes about a process sits under /proc/<pid>/ :
$ ls /proc/12503 cmdline cwd environ exe fd limits maps root stat status ...
Enter fullscreen mode
Exit fullscreen mode
cmdline is the launching command. cwd is a symlink to the working directory and exe a symlink to the binary on disk:
$ ls -l /proc/12503/ { cwd,exe } ... /proc/12503/cwd - > /home/ubuntu ...…