Skip to content


Find and connect to Windows (Samba) shares from Linux

There are times when we have to interact with Windows machines in our environment and we need to access Windows shares from our Linux PC. This guide tells you how to find and connect to Windows shares from your Linux machine.

First we need to install smbclient

On Debian

sudo aptitude install smbclient

It will ask

1. for workgroup, type in the same workgroup you have configured on Windows
2. whether or not to use encrypted passwotd, select ‘Yes’
3. if it should get WINS server’s IP address from DHCP or not, select ‘Yes’ or ‘No’ as appropriate.

On Red hat/Centos/Suse

yum install smbclient

Let’s first find which machines are advertising their shares

findsmb
                                *=DMB
                                +=LMB
IP ADDR          NETBIOS NAME     WORKGROUP/OS/VERSION
---------------------------------------------------------------------
192.168.2.57   MARIA-PC  +[WORKGROUP] [Windows 5.1] [Windows 2000 LAN Manager]
192.168.2.71   JOHN-PC     +[WORKGROUP] [Windows 5.1] [Windows 2000 LAN Manager]

Next find what are shared on the windows box

sbmclient -L windows_machine_name -U username

For me it would be like this

smbclient -L MARIA-PC -U testuser
Password:
Domain=[MARIA-PC] OS=[Windows 5.1] Server=[Windows 2000 LAN Manager]

        Sharename       Type      Comment
        ---------                ----           -------
        IPC$                 IPC           Remote IPC
        REPORTS          Disk
        ADMIN$            Disk         Remote Admin
        C$                    Disk         Default share
Domain=[MARIA-PC] OS=[Windows 5.1] Server=[Windows 2000 LAN Manager]

        Server                   Comment
        ---------                    -------

        Workgroup            Master
        ---------                    -------

Provide the password for the testuser you have on the windows PC.

Now we want to mount a shared directory

First create a directory to mount the share on

mkdir /mnt/mount_point_name

In my case, it is

mkdir /mnt/reports

Next mount the share on the above created mount point directory

mount -t smbfs -o username=windows_username,password=windows_pc_ password   //windows_pc_name_or_IP/share_name   /mnt/mount_point_name

For me, it looks like below

mount -t smbfs -o username=testuser,password=secret //192.168.2.57/$C /mnt/reports

Change directory to the mount point

cd /mnt/reports

to see files/folders in the windows share. Now you can copy to/from it as if it was a local directory, do

ls 

 

 

Share The Knowledge:
  • Print this article!
  • Digg
  • del.icio.us
  • Facebook
  • Google Bookmarks
  • blogmarks
  • Diigo
  • E-mail this story to a friend!
  • LinkedIn
  • Live
  • Reddit
  • StumbleUpon
  • Twitter
  • Blogosphere News
  • Identi.ca
  • Slashdot
  • Technorati

Posted in Microtips.


0 Responses

Stay in touch with the conversation, subscribe to the RSS feed for comments on this post.



Some HTML is OK

or, reply to this post via trackback.