0

Is there a command line I can issue to see what directory another user is currently working in? This would be like using >pwd but for the other user.

John Lewis
  • 712
  • 7
  • 15

1 Answers1

2

There's a cwd symlink in every process' /proc folder, but as a commoner you wouldn't have any rights to read any other's proc folder - only your own:

[marc@panic home]$ ls -l /proc/$$/cwd
lrwxrwxrwx. 1 marc marc 0 May  5 12:06 /proc/16257/cwd -> /home
                                                          ^^^^^---cwd
[marc@panic home]$
            ^^^^---cwd
Marc B
  • 356,200
  • 43
  • 426
  • 500
  • What if I have sudo as root. Can I run cwd for another user? – John Lewis May 05 '14 at 18:12
  • Sure you can do the above, but you need the process id to query by. Note that "the current working directory" does not make sense in relation to a user account, but only of a process. Different processes of a user can and will have different working directories. A user account does not have a working directory. – arkascha May 05 '14 at 18:13
  • Assuming I had the following: >who jsmith console Apr 30 10:03 adam ttys000 Apr 30 10:04 bob ttys001 Apr 30 10:04 What command could I issue with this technique to see the 'cwd' of bob? – John Lewis May 05 '14 at 18:25
  • that doesn't tell you anything. you've got a username. but that shell can have MANY background tasks, and each task can have a different working directory.if you want to know what a user's terminal shell is sitting at for a directory, then you'd have to figure out what process is their shell (e.g. bash, sh, csh, etc..) and get that process' cwd. – Marc B May 05 '14 at 18:27