LinuxQuestions.org
Visit Jeremy's Blog.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Server
User Name
Password
Linux - Server This forum is for the discussion of Linux Software used in a server related context.

Notices


Reply
  Search this Thread
Old 03-22-2012, 05:20 AM   #1
centos123
Member
 
Registered: Apr 2011
Posts: 397

Rep: Reputation: 16
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...
 
Old 03-22-2012, 05:47 AM   #2
dln
LQ Newbie
 
Registered: Mar 2012
Posts: 6

Rep: Reputation: Disabled
'smbstatus' will show that info

man smbstatus

and Useful Samba Networking Commands

Last edited by dln; 03-22-2012 at 06:07 AM.
 
1 members found this post helpful.
Old 03-29-2012, 02:19 AM   #3
centos123
Member
 
Registered: Apr 2011
Posts: 397

Original Poster
Rep: Reputation: 16
i think these command is for domain server...i samba server not domain server.
 
Old 03-29-2012, 02:27 AM   #4
descendant_command
Senior Member
 
Registered: Mar 2012
Posts: 1,876

Rep: Reputation: 643Reputation: 643Reputation: 643Reputation: 643Reputation: 643Reputation: 643
Less thinking might be in order ...
 
Old 03-29-2012, 02:48 AM   #5
osantos
LQ Newbie
 
Registered: Mar 2011
Posts: 11

Rep: Reputation: 0
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
 
Old 03-29-2012, 05:24 AM   #6
centos123
Member
 
Registered: Apr 2011
Posts: 397

Original Poster
Rep: Reputation: 16
Talking

Quote:
Originally Posted by descendant_command View Post
Less thinking might be in order ...
more thinking might be in dis-order for server...
 
Old 03-29-2012, 05:28 AM   #7
descendant_command
Senior Member
 
Registered: Mar 2012
Posts: 1,876

Rep: Reputation: 643Reputation: 643Reputation: 643Reputation: 643Reputation: 643Reputation: 643
Quote:
Originally Posted by centos123 View Post
more thinking might be in dis-order for server...
So did you try those commands on your samba server?
Did smbstatus produce the info you asked for?
 
Old 04-10-2012, 01:05 AM   #8
centos123
Member
 
Registered: Apr 2011
Posts: 397

Original Poster
Rep: Reputation: 16
thanks din ..
smbstatus command is good one.learned one more command
 
Old 04-13-2012, 05:21 AM   #9
jsveiga
Member
 
Registered: Aug 2005
Location: Brazil
Distribution: debian on servers and embedded, kubuntu elsewhere
Posts: 31

Rep: Reputation: 1
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";
}
 
Old 04-13-2012, 06:26 AM   #10
centos123
Member
 
Registered: Apr 2011
Posts: 397

Original Poster
Rep: Reputation: 16
from where you get this code?
 
Old 04-13-2012, 02:40 PM   #11
jsveiga
Member
 
Registered: Aug 2005
Location: Brazil
Distribution: debian on servers and embedded, kubuntu elsewhere
Posts: 31

Rep: Reputation: 1
Quote:
Originally Posted by centos123 View Post
from where you get this code?
From my server; I wrote it somewhere in the last century. Is it too ugly?
 
Old 04-13-2012, 11:53 PM   #12
centos123
Member
 
Registered: Apr 2011
Posts: 397

Original Poster
Rep: Reputation: 16
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..
 
Old 04-14-2012, 12:09 AM   #13
TommyC7
Member
 
Registered: Mar 2012
Distribution: Slackware, CentOS, OpenBSD, FreeBSD
Posts: 530

Rep: Reputation: Disabled
Does descendent_command not get a thank you or an apology?
 
Old 04-14-2012, 05:45 AM   #14
jsveiga
Member
 
Registered: Aug 2005
Location: Brazil
Distribution: debian on servers and embedded, kubuntu elsewhere
Posts: 31

Rep: Reputation: 1
Quote:
Originally Posted by centos123 View Post
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 :-) )
 
Old 04-19-2012, 12:33 AM   #15
centos123
Member
 
Registered: Apr 2011
Posts: 397

Original Poster
Rep: Reputation: 16
Quote:
Originally Posted by descendant_command View Post
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 .
 
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
Accessing SAMBA shared folder through Ftp (PROFTPD) vvagao Debian 1 10-13-2009 12:49 PM
Windows machine can not see my samba shared folder. mtlhd Linux - Server 13 05-09-2009 09:01 PM
Accessing Linux shared folder from Windows XP bekiricli Linux - Newbie 8 02-10-2009 03:50 PM
how do i connect to a windows shared folder using samba? winstone5000 Linux - Networking 1 12-19-2005 10:38 AM
Samba not accessing my Windows Shared folders Felpipe Linux - Networking 3 08-04-2005 08:34 AM

LinuxQuestions.org > Forums > Linux Forums > Linux - Server

All times are GMT -5. The time now is 03:40 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration