LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Newbie (https://www.linuxquestions.org/questions/linux-newbie-8/)
-   -   how to know the current path (https://www.linuxquestions.org/questions/linux-newbie-8/how-to-know-the-current-path-4175551207/)

QWE123 08-19-2015 09:25 PM

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

cliffordw 08-20-2015 12:44 AM

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

QWE123 08-20-2015 02:14 AM

Quote:

Originally Posted by cliffordw (Post 5408277)
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

cliffordw 08-20-2015 05:46 AM

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.

cliffordw 08-20-2015 05:47 AM

Another approach: as root, run:

Code:

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


All times are GMT -5. The time now is 06:25 AM.