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 

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 ... 

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 ... /proc/12503/exe -> /bin/sleep 

status carries the owner's numeric user IDs, which grep Uid /proc/12503/status pulls out and id resolves against /etc/passwd and /etc/group. The same directory holds environ, the process environment block.

htop shows all of this for every process on the machine, not just yours. The pstree output in a normal shell lists init, cron, sshd and the rest of the system's daemons alongside your own processes. Read that from the point of view of someone who just got an unprivileged shell on the box, and it reads as reconnaissance.

Command lines are the first thing worth pulling. Anything passed to a process as an argument stays in cmdline for the life of the process: a database password, an API token, a connection string with credentials in it. htop prints it in the clear to anyone watching the process table. That is the concrete reason not to pass secrets on the command line. Once a process is launched with a secret in argv, every user who can read /proc can read the secret for as long as the process lives.

exe and cwd show where each process runs from and which directories are in play, including home directories and install paths. The owner IDs in status map processes to accounts without your needing to be those accounts.

Hit F5 and htop draws the process tree. init at PID 1 spawns sshd, which forks a child per connection, which starts a login shell:

init └─sshd -D └─sshd └─bash 

That hierarchy shows who is logged in over SSH and which shells are live sessions rather than daemons. pstree -a prints the same tree with arguments attached.

Then the setuid binaries, which are the escalation shortlist. passwd writes to the root-only /etc/shadow even when an ordinary user runs it, because of the s bit in its mode:

$ ls -l /usr/bin/passwd -rwsr-xr-x 1 root root 54256 Mar 29 2016 /usr/bin/passwd 

The s means the program runs as the file's owner, root, regardless of who started it. One line enumerates every such binary:

find /bin -user root -perm -u+s 

For an attacker that is the first pass at finding a way up. For whoever runs the box it is the audit: every setuid-root binary is something you are trusting not to be exploitable, so the list should be short and every entry should have a reason to be there.

None of this needs root. It is the same /proc that htop reads, open to any shell on the machine. If you want to narrow it, mount /proc with hidepid so unprivileged users see only their own processes, and keep secrets out of argv in the first place.