LinuxQuestions.org
Welcome to the most active Linux Forum on the web.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > Programming
User Name
Password
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.

Notices


Reply
  Search this Thread
Old 07-10-2008, 10:18 AM   #1
fab1234
LQ Newbie
 
Registered: Jul 2008
Posts: 8

Rep: Reputation: 1
show exe path of a process


hi
does anyone know how to show the path of the executable in addition to the command with the ps command. or maybe there isnt any connection beween the path and the process?
thanks
fab
 
Old 07-10-2008, 10:56 AM   #2
smoked kipper
Member
 
Registered: May 2008
Location: UK
Distribution: Slackware,Slamd64
Posts: 81

Rep: Reputation: 15
I don't think ps can give you the full path, but you can get it from /proc/<pid>/exe.
 
Old 07-10-2008, 10:57 AM   #3
unSpawn
Moderator
 
Registered: May 2001
Posts: 29,415
Blog Entries: 55

Rep: Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600
Depending on what you exactly want (examples?) it may be easier, more efficient, safer (just like find vs ls) to rely on other tools than 'ps' like 'pgrep' or 'lsof' or 'readlink -f /proc/$PID/exe' like smoked kipper already posted.
 
1 members found this post helpful.
Old 07-10-2008, 11:49 AM   #4
salasi
Senior Member
 
Registered: Jul 2007
Location: Directly above centre of the earth, UK
Distribution: SuSE, plus some hopping
Posts: 4,070

Rep: Reputation: 897Reputation: 897Reputation: 897Reputation: 897Reputation: 897Reputation: 897Reputation: 897
I'm not sure exactly what you want, but the man page for ps gives some options that might help (ps seems to list the path to some processes, but not all...I'm not sure on what basis it chooses the ones that it does):

So, you could try
ps -ef
ps -eLf
ps axms

all of which give some variant or another on information about the processes.
 
Old 07-10-2008, 08:41 PM   #5
jiml8
Senior Member
 
Registered: Sep 2003
Posts: 3,171

Rep: Reputation: 116Reputation: 116
ps lists the command line that was entered. So if the command line had the full path to the command, then that is listed. Otherwise, not.
 
Old 07-11-2008, 06:39 AM   #6
fab1234
LQ Newbie
 
Registered: Jul 2008
Posts: 8

Original Poster
Rep: Reputation: 1
thanks a lot! i used
readlink -f /proc/$PID/exe
 
1 members found this post helpful.
Old 10-08-2008, 10:58 PM   #7
gloriajw
LQ Newbie
 
Registered: Oct 2008
Posts: 5

Rep: Reputation: 0
Quote:
Originally Posted by fab1234 View Post
thanks a lot! i used
readlink -f /proc/$PID/exe
This did not work for me. It only showed me:

/bin/env

since I was running a script.

I had to do this:

cat /proc/$PID/cmdline

to get my answer.

~G~
 
Old 10-12-2008, 09:12 AM   #8
jan61
Member
 
Registered: Jun 2008
Posts: 235

Rep: Reputation: 47
Moin,

Quote:
Originally Posted by gloriajw View Post
...
cat /proc/$PID/cmdline
The -o option of ps can be used to get various process information:
Code:
ps -o cmd= -p $PID
Jan
 
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
why path don't show whole cnhawk386 Linux - Newbie 2 09-07-2007 08:36 AM
command to show full directory path cuco76 Linux - Newbie 2 10-12-2006 08:36 PM
Show Library Path for PHP on Linux? daprezjer Linux - Software 1 03-20-2005 08:35 PM
configuring terminal so not to show full path harshnoise SUSE / openSUSE 2 02-26-2005 07:42 AM
How to show your location / path? Echo Kilo Linux - General 2 12-19-2004 01:40 PM

LinuxQuestions.org > Forums > Non-*NIX Forums > Programming

All times are GMT -5. The time now is 11:35 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration