Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Another user's pwd

Status
Not open for further replies.

theotyflos

Programmer
Oct 15, 2000
132
GR
Hi all,

Is it possible to find another user's current working directory? If yes, how?

Theophilos.

-----------

There are only 10 kinds of people: Those who understand binary and those who don't.
 
One way is

finger username

If using ksh, you can do

echo ~username

Greg.
 
Sorry ... misread. That's for their home dir. No, I don't know of any way to find their current dir.

Greg.
 
Thanks anyway.

Theophilos.

-----------

There are only 10 kinds of people: Those who understand binary and those who don't.
 
Here's a thought. This works on Solaris.

/usr/ucb/ps -eauxwww

will show the environment for all processes, including the value for PWD (the current directory). You could take the output from the command above and filter it in some way.

Any use?

Greg.
 
Unfortunatelly not, I'm on SCO.

Theophilos.

-----------

There are only 10 kinds of people: Those who understand binary and those who don't.
 
But if they have multiple sessions, they're likely to have multiple "current working directories"

Bear in mind that even if you find out a singular answer, there is no reason why you should have any access to it.

What are you intending to do with that information once you have it?

If you're trying to give a file to a user, then I would suggest you choose a standard place for each user, say [tt]~user/incoming[/tt]


--
 
Salem, first of all thanks for the answer.

Actually I'm not trying to accomplish anything by finding it. I was just wondering if it is possible.

> But if they have multiple sessions ...
Could also look for a specific tty.

Thanks anyway.

Theophilos.

-----------

There are only 10 kinds of people: Those who understand binary and those who don't.
 
You could look at the .history file in the user's home directory.
like tail -f .history

each shell is different, like aix has .sh_history
 
First of all, it doesn't make much sense to talk about a user's pwd. It only makes sense to talk about a process's pwd. You can talk about the pwd for a shell process being used by a given user. If that's the shell they happen to be working on, that's what you might call their pwd.


Now, I don't think this helps, but it might inspire:

On Linux, you have a /proc directory that's really a virtual filesystem that reflects the state of the kernel. Among other things, it contains a "directory" for each running process. One file in each directory is called cwd, and is a symbolic link to the current working directory of that process.

Now, SCO might have something similar. It should definitely be possible, unless the kernel keeps the information from priveleged users for security reasons. Someone might want to look at the system calls available on SCO and see what kinds of things are possible.
 
You may consider to take a look at the lsof program.
This stand for LiSt Open Files.
You may grep the output produced for (b]cwd[/b] (current working directory).
ftp://vic.cc.purdue.edu/pub/tools/unix/lsof/

Hope This Help, PH.
Want to get great answers to your Tek-Tips questions? Have a look at FAQ219-2884
 
On Solaris you can use the command [tt]pwdx[/tt] to get a process' current working directory. See the man pages for useage.

Hope this helps.

 
Thank you all guys for your thoughts and your help. I have used lsof in the past but for some strange reason forgot about it :)

Theophilos.

-----------

There are only 10 kinds of people: Those who understand binary and those who don't.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top