I run a number of linux servers with VMware Server 2. When their response time is not so hot or the load average goes up, I open up top to see what's going on, or for our production servers I have top open all day long. The issue is, the cmdline of vmware-vmx processes is really long, for example:

/usr/lib/vmware/bin/vmware-vmx -# product=2;name=VMware Server;version=2.0.2;buildnumber=203138;licensename=VMware GSX Server for Linux;licenseversion=3.0 build-203138; -@ pipe=/tmp/vmhsdaemon-0/vmxaf9a31943e9065f0;readyEvent=55 /var/lib/vmware/Virtual Machines/Kyle.vmwarevm/Kyle.vmx

So in top all I see is:

 4135 root      20   0  593m 324m 289m S   21  4.2   3038:04 /usr/lib/vmware/bin/vmware-vmx -# product=2;name=VMware Server;
 4106 root      10 -10  997m 399m 346m S    9  5.1   1135:25 /usr/lib/vmware/bin/vmware-vmx -# product=2;name=VMware Server;
 4074 root      20   0  833m 110m  97m S    2  1.4 722:19.38 /usr/lib/vmware/bin/vmware-vmx -# product=2;name=VMware Server;

In VMWare Server 1, each VM would run as it's own user so I could easily tell which one was which. Not so with VMWare Server 2. In lieu of buying a really wide monitor or a triple monitor setup, is there any way I can alter the cmdline of these running processes so I can easily identify which one's which? I know the processes can alter the cmdline of themselves... and I can read (but not write to) /proc/nnn/cmdline...

Is there any way (as root) to alter the cmdline of a running process?

7 Answers 7


Although probably noone is going to use VMWare Server any more, this problem would arise with other processes as well. You really should look at htop instead, it allows for side-scrolling to read the entire command line and displays process trees:


As for your question, changing the command line of a process which is runnnig already is likely to be possible only by overwriting data at the memory address of its ARGV[0]. To my knowledge, no tool is yet available which just would do changecmdline 4652 "foo process". Further discussion: http://stupefydeveloper.blogspot.de/2008/10/linux-change-process-name.html


How about the following:

watch 'ps -eo pid,pcpu,args | grep vmware'

Watch will run the command every 2 seconds. pcpu is cpu percentage.

  • This is pretty close. I could probably combine this with sed to show exactly what I want. If nobody else provides the exact answer I'm looking for, I'll assume it can't be done and will probably accept this one. Thanks!
    – Josh
    Sep 25, 2010 at 15:14

This is indeed an annoying problem.

The real solution is posted here:


The script is NOT pretty but it works.


Short answer, I don't think it is possible without recompiling the kernel. I've checked top and it's definitely pulling it from /proc:
strace top -c 2>&1 | grep "proc"
open("/proc/6501/stat", O_RDONLY) = 4
open("/proc/6501/statm", O_RDONLY) = 4
open("/proc/6501/cmdline", O_RDONLY) = 4

As you say, /proc/pid/cmdline is not writeable by root. Have you considered running them with a wrapper program? eg. bash script ./vmware that just executes
/usr/lib/vmware/bin/vmware-vmx -# product=2;name=VMware Server;version=2.0.2;buildnumber=203138;licensename=VMware GSX Server for Linux;licenseversion=3.0 build-203138; -@ pipe=/tmp/vmhsdaemon-0/vmxaf9a31943e9065f0;readyEvent=55 $1"

It's worth noting that top only truncates when it's out of space. Why not open top, hit f and remove any fields you're not using. You might just find it leaves enough space for the entire cmdline


Not a direct answer to your question, but perhaps an answer to your problem:

  1. Use LSOF to find out which PIDs are using which VMDKs
  2. Use ps and grep for those PIDs

This could be easily scripted, I don't have a Linux console opened right now though. Exercise left for the reader.

  • True, I could script that. I'm basically using ps and grep right now -- finding the top orocess, switching screens, ps awwwx | grep $pid, and this gives me the VMX name, it's just tedious!
    – Josh
    Sep 24, 2010 at 13:31
  • Yeah, script it from the other side.
    – mfinni
    Sep 24, 2010 at 13:34


while true; do
    clear; ps -eo pid,pcpu,args | grep vmx|grep $DIRNAME  |awk '{ print $1 " " $2 " " $NF}'| sort -rn -k 2; sleep $DELAY;

Try this:

A=`ps -e -o pid,cmd| grep vmware-vmx | grep -v match | awk 'BEGIN {print "{" } {gsub(/^.*\//, "", $NF); print "if (match($0, / *" $1 " /)) { sub(\"vmware-vmx          \",\"" "%-20s" "\",$0); printf($0,\"" $NF "\"); print \"\";} else "} END {print "print $0 }"}'`
top | awk "$A"

The script works as a filter to TOP output and replaces "vmware-vmx" with VM name. It assumes .vmx file is no more than 20 chars. This is because you have to preserve the line size generated by top.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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