Linux Process Execution Directory

by bluemedora_editor on May 25, 2011

Finding the directory from which a process is executing is often helpful. It can be done simply with a linux kernel newer than 2.0 by using the /proc virtual directory.

Discover your kernel version:

uname -a

The /proc/<PID>/exe soft link points to the directory from which the process is executing.  If a process’s PID is unknown, it can be discovered using the ps tool:

ps awxx | grep <Process Name>


Combining the above logic with some other common linux tools could yield an example bash command as follows:

ls -l /proc/$(ps awxx | grep cupsd | grep -v grep \ | awk -F' ' '{print $1}')/exe | awk -F' -> ' '{print $2}'

This simply parses the long format the soft link, printing the cupsd execution directory. Example output:




Get started

Try BindPlane for free. No credit card required.

Sign up
True Visibility
BindPlane for VMware vRealize Operations

True Visibility allows cloud management teams to use VMware vRealize’s powerful machine learning and capacity planning engine across their entire hybrid cloud environment.

Azure Monitor...everything
BindPlane for Microsoft Azure Monitor

Make Azure Monitor your first-pane-of-glass across your entire multi-cloud, multi-database or hybrid platform environment.

Thank you for contacting us. Your information was received. We'll be in touch shortly.