Samba includes the necessary tools to find out what users are accessing shares and their associated IP addresses. Learn how to do this with a single command.
When you're a network administrator, one of your tasks might be managing directories that are shared across a network. If Linux is a part of your data center game, (which it probably is), chances are good you employ Samba. If that's the case, there will be times when you might need to know what shares are being accessed and by what machine.
This can come into play if you need to reboot a server hosting a Samba share, or if you suspect unwanted activity within a share. Either way, how do you find out who's accessing the shares on a particular machine? I'm going to show you how.
SEE: Deploying containers: Six critical concepts (free PDF) (TechRepublic)
What you'll need
- The ability to log in to the machine hosting the Samba shares
- A user account with sudo privileges
How to tell if a Samba share is in use
Log in to the machine hosting the Samba share and issue the command:
The output of the command will show you the user connecting to the share, the hostname and IP address they are connecting from, the share they are accessing, and a bit more information than you probably need. If that output is too much for you, use the -S option to only list the pertinent share information with the command:
sudo smbstatus -S
And that's all there is to finding out if a Samba share is in use. With this information in hand, you can act accordingly. Inform your users to close any file they are working with in the share or if you might find a user working within a share that doesn't belong. Either way, you now have the necessary commands at your fingertips to make your Samba admin tasks a bit easier.
- Top five open source Linux server distributions (TechRepublic Premium)
- How to auto mount FAT32-formatted drives in Samba (TechRepublic)
- How to enable Samba connections via hostname (TechRepublic)
- How to share a folder from a Linux data center with this easy Samba GUI (TechRepublic)
- Why and how to replace Windows 7 with Linux Mint (ZDNet)
- It takes work to keep your data private online. These apps can help (CNET)
- Open Source Tech: More must-read coverage (TechRepublic on Flipboard)