When I select Restart from the Apple menu and get the alert "There is a user sharing this computer...", I would like to know which user (e.g. their IP address or some other identification) is sharing. Is there a (Terminal) command to discover the addresses of sharing users? (I'm not suspecting unauthorised users, rather I am trying to identify the source of a problem).
For network sharing you could do following in Terminal.
Assuming you have the file sharing enabled.
Applications using a file reference to your computer can mount a remote disk automatically, as long as the computer is on the network. A command like
netstat -na | grep 548
will list what machine and user is connected by AFP.
If you simply type
netstat it will list all active connection.