How to get the command line args passed to a running process on unix/linux systems?

Hemant picture Hemant · May 4, 2009 · Viewed 194.4k times · Source

On SunOS there is pargs command that prints the command line arguments passed to the running process.

Is there is any similar command on other Unix environments?

Answer

markus_b picture markus_b · May 4, 2009

There are several options:

ps -fp <pid>
cat /proc/<pid>/cmdline | sed -e "s/\x00/ /g"; echo

There is more info in /proc/<pid> on Linux, just have a look.

On other Unixes things might be different. The ps command will work everywhere, the /proc stuff is OS specific. For example on AIX there is no cmdline in /proc.