Beyond the Sky

The place where surface stop and share the experience of life

xprop and pgrep

,

While surfing through fluxbox wiki, I learn this 2 interesting commands xprop and pgrep.

xprop are use to display the property for any X item, you can just type xprop at your terminal and click on any X item you like to check the properties. You can type xprop -root to check the root windows properties and also other active programs, for example gaim.

 xprop -name gaim

To grep the process ID for the active 'gaim', you can put
 xprop -name gaim | grep PID


Here comes in another command with more simple result which returns you only the pid.
pgrep gaim


Bare in mind, if you have multiple same services running, it will return a list of pid, let say apache2. To kill process based on the id, now you may do so with
kill `pgrep gaim`

It always have another way to do it, simply killall gaim will do the same thing. But pgrep did more than that, you can list all process created by root user with

This will list all the process running by root with the process names.
pgrep -l -u root


Combine ps and pgrep to display the details of a process with name apache2
ps -fp `pgrep -d' ' -x apache2`


This 2 lines does the same thing as above.
ps aux | grep apache2
ps -fp $(pgrep -d' ' -x apache2)

How to add IPv6 address to the network interface?I had a bad dream

Comments

Unregistered user Thursday, March 30, 2006 4:00:36 AM

koekoecrunch writes: 1st time visiting ye page... so zanggih one =..=" i only use apache to bypass gameguard... nothing else :x nice page to confuse me :D

Write a comment

New comments have been disabled for this post.