LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Server (https://www.linuxquestions.org/questions/linux-server-73/)
-   -   how to check who's accessing samba shared folder from windows (https://www.linuxquestions.org/questions/linux-server-73/how-to-check-who%27s-accessing-samba-shared-folder-from-windows-935842/)

centos123 03-22-2012 05:20 AM

how to check who's accessing samba shared folder from windows
 
i had a file server (samba server) ,windows user save their files on thier shared in linux.i want to know did i know which windows user is accessing server shared dir.either by thier ip address...

dln 03-22-2012 05:47 AM

'smbstatus' will show that info

man smbstatus

and Useful Samba Networking Commands

centos123 03-29-2012 02:19 AM

i think these command is for domain server...i samba server not domain server.

descendant_command 03-29-2012 02:27 AM

Less thinking might be in order ... :)

osantos 03-29-2012 02:48 AM

Webmin provides open connection info
 
If you have webmin installed with the samba module and you access the share info, you will find a "View connections" button that lists all open connections to that share.

You might also use the smbstatus command.

Best regards
Oriol

centos123 03-29-2012 05:24 AM

Quote:

Originally Posted by descendant_command (Post 4639360)
Less thinking might be in order ... :)

more thinking might be in dis-order for server...:tisk:

descendant_command 03-29-2012 05:28 AM

Quote:

Originally Posted by centos123 (Post 4639534)
more thinking might be in dis-order for server...:tisk:

So did you try those commands on your samba server?
Did smbstatus produce the info you asked for?

centos123 04-10-2012 01:05 AM

thanks din ..
smbstatus command is good one.learned one more command

jsveiga 04-13-2012 05:21 AM

Hi, I use this "wrapper" to smbstatus to get an output with easier identification of locked files per user:

Code:

#!/usr/bin/perl
use warnings;
use strict;

my @smbstatus = qx{/usr/bin/smbstatus -b};

my %users = ();

for (@smbstatus) {
    chomp;
    next if (/^$/);
    next if ( !/^\s*?\d*?\s/ );
    s/^ *//;
    my ( $pid, $user, $group, $pc, $time ) = split / +/;
    $users{$pid} = "$user @ $pc :\n\n";
}

@smbstatus = qx{/usr/bin/smbstatus -L};

my @lfiles = ();

for (@smbstatus) {
    chomp;
    next if (/^$/);
    next if ( !/^\s*?\d*?\s/ );
    push @lfiles, $_;
}

for my $pid ( sort( keys(%users) ) ) {
    next unless ( grep( /^$pid/, @lfiles ) );
    print $users{$pid};
    my @files = grep( /^$pid/, @lfiles );
    for (@files) {
        my @r =  split(/ +/,substr($_,0,-27));
        print "$r[0]\t$r[1]\t$r[3]\t".substr($_, 52, -27)."\n";
    }
    print "_________________________________________\n\n";
}


centos123 04-13-2012 06:26 AM

from where you get this code?

jsveiga 04-13-2012 02:40 PM

Quote:

Originally Posted by centos123 (Post 4651760)
from where you get this code?

From my server; I wrote it somewhere in the last century. Is it too ugly?

centos123 04-13-2012 11:53 PM

not is not ugly at all....but i can't test it coz iam using file server for company so i didnot test it on running server..

TommyC7 04-14-2012 12:09 AM

Does descendent_command not get a thank you or an apology?

jsveiga 04-14-2012 05:45 AM

Quote:

Originally Posted by centos123 (Post 4652298)
not is not ugly at all....but i can't test it coz iam using file server for company so i didnot test it on running server..

Oh, I assure* it can do no harm; all it does is take the output of the smbstatus and reorganize it, grouping the information per user/client pc.

I have another script though to "kick" user connections (I named it really "kick"); you go "kick john.smith", and it finds the PIDs for the guy's samba connections/locked files, then kills them. This one does harm :) , but it is eventually useful (when windows/app crashes and leaves file locked in the server)

(*the assurance of a random guy in a forum means nothing, but you can read the script :-) )

centos123 04-19-2012 12:33 AM

Quote:

Originally Posted by descendant_command (Post 4639539)
So did you try those commands on your samba server?
Did smbstatus produce the info you asked for?

yes this command show active access of sharing file and its sufficient .


All times are GMT -5. The time now is 08:17 PM.