LinuxQuestions.org
Help answer threads with 0 replies.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!

Notices


Reply
  Search this Thread
Old 08-19-2015, 10:25 PM   #1
QWE123
Member
 
Registered: Nov 2014
Posts: 55

Rep: Reputation: Disabled
how to know the current path


in the system , there are many user are logining and working in the shell , if I would like to know which path the specific user is working now ( eg. may be the user is cd to /tmp and working in it , what I hope to do is to know the user is working in /tmp ) , would advise what can I do ?

thanks
 
Old 08-20-2015, 01:44 AM   #2
cliffordw
Member
 
Registered: Jan 2012
Location: South Africa
Posts: 503

Rep: Reputation: 189Reputation: 189
Hi,

To find all the processes with /tmp as the current working directory, this may help:

Code:
lsof|egrep ' cwd +DIR +.+ /tmp'
You'll have to do this as root. The results may also contain processes which aren't interactive user sessions.

Regards,

Clifford
 
Old 08-20-2015, 03:14 AM   #3
QWE123
Member
 
Registered: Nov 2014
Posts: 55

Original Poster
Rep: Reputation: Disabled
Quote:
Originally Posted by cliffordw View Post
Hi,

To find all the processes with /tmp as the current working directory, this may help:

Code:
lsof|egrep ' cwd +DIR +.+ /tmp'
You'll have to do this as root. The results may also contain processes which aren't interactive user sessions.

Regards,

Clifford
thanks reply ,

if I would like to know the which path ( not only /tmp ) the specific user is working , what can I do ? thanks
 
Old 08-20-2015, 06:46 AM   #4
cliffordw
Member
 
Registered: Jan 2012
Location: South Africa
Posts: 503

Rep: Reputation: 189Reputation: 189
Have a look at the lsof command and it's man page please.

"lsof -d cwd" will show you the Current Working Directory (CWD) for each process on the system, irrespective of where that directory is.
 
Old 08-20-2015, 06:47 AM   #5
cliffordw
Member
 
Registered: Jan 2012
Location: South Africa
Posts: 503

Rep: Reputation: 189Reputation: 189
Another approach: as root, run:

Code:
ls -ld /proc/*/cwd
/proc/processid/cwd is a symbolic link to the CWD for that process.
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

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
Current path Huamin Linux - Software 2 05-07-2012 12:22 AM
[SOLVED] How to get the absolute path of the running executable file and current work path ? 915086731 Programming 3 11-01-2011 10:28 AM
How to shorten current path name cianoz Linux - Newbie 14 03-14-2011 08:50 AM
double current directory in path Saulo SUSE / openSUSE 5 04-20-2006 07:19 PM
Placing current path in the prompt zepplin611 Linux - General 2 05-13-2004 01:07 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie

All times are GMT -5. The time now is 02:39 AM.

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
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration