How to View Environment Variables in htop on Ubuntu
Managing processes on Ubuntu often requires inspecting their
configuration to troubleshoot issues or verify settings. This article
explains how to use the htop utility to identify a specific
process and then view its environment variables using standard Linux
commands. While htop itself does not display environment
variables directly, it serves as the primary tool for locating the
necessary process ID.
Install and Launch htop
Ensure htop is installed on your Ubuntu system by
running sudo apt install htop. Launch the utility by typing
htop in your terminal. The interface displays a list of
running processes along with their resource usage.
Identify the Process ID
Navigate through the process list using the arrow keys to select the
target process. You can also press F3 to search for a
specific process name. Once highlighted, note the number listed in the
PID column on the left side of the screen.
View Environment Variables
Press F10 or q to exit htop
and return to the command line. Use the Process ID you recorded to view
the environment variables. You can use the ps command with
the following syntax:
ps e -p <PID>
Alternatively, you can read the environment file directly from the proc filesystem:
cat /proc/<PID>/environ | tr '\0' '\n'
Replace <PID> with the actual number you found in
htop. The tr command converts the null
separators used in the proc file into newlines for readable output.
Summary
Using htop to find the PID and standard commands to
inspect variables provides a reliable workflow for process analysis on
Ubuntu. This method ensures you access accurate environment data without
needing specialized plugins.