Access Windows Shares from Linux

Posted on in Categories , , , last updated November 26, 2006

Q. How do I Access Windows share from Linux command prompt? I would like to be able to access shared folders on Windows machines from my Linux system.

A. There are two ways. Use command line tool called smbclient or you can mount windows shares the mount command. Another option is use GUI tools. Please refer previous articles about access windows share from Linux:

( a ) Mount Windows share using mount command

This is simple way to share data between windows and linux system. You would like to access MS-Windows share called //windowsserver/sharename by mounting to /mnt/win directory under Linux system. Type the following command (replace username, windows server name, share name and password with actual values):

# mkdir -p /mnt/win
# mount -t smbfs -o username=winntuser,password=mypassword //windowsserver/sharename /mnt/win
# cd /mnt/win
# ls -l

For the share //windowsserver/sharename to be automatically mounted at every system start (after reboot), insert an option in the file /etc/fstab:
# vi /etc/fstab
Append following line (written in a single line)
//windowserver/share /mnt/win smbfs
auto,gid=users,fmask=0664,dmask=0775,iocharset=iso8859-15, credentials=/etc/sambapasswords 0 0

Next create the password file /etc/sambapasswords:
# vi /etc/sambapasswords
Now add following content:
username = winntuser
password = mypassword

Save and close the file. Make sure only root can access your file:
# chown 0.0 /etc/sambapasswords
# chmod 600 /etc/sambapasswords

Other solutions

( b ) Browse a Samba or MS Windows share using smbclient

( c ) Browse a Samba or MS Windows share in Nautilus (GUI Option)

Posted by: Vivek Gite

The author is the creator of nixCraft and a seasoned sysadmin and a trainer for the Linux operating system/Unix shell scripting. He has worked with global clients and in various industries, including IT, education, defense and space research, and the nonprofit sector. Follow him on Twitter, Facebook, Google+.

24 comment

  1. Just to let you know – if you put a space with the equals sign in your credentials file, like this:

    username = someuser
    password = somepass

    it will error out ‘permission denied’

    You HAVE to have no spaces on each line like this:


  2. Did the above, mount is there, I can acces it, but I can’t dump it to tape
    using the dump command.?


  3. Would someone be so kind as to explain what the:


    part of the fstab is for.

    New to Linux, please assume I’m stupid.

  4. I’ve seen so many distributions, there is no one can browse share [though nautilus does, but .. open file in windows share with nautilus is .. nightmare ] or “create a share” like genuine Windows..Just by right mouse click..

  5. Hello, I have a small problem with windows and linux in the same network. I want from linux see all PC in the network. How I can do that with samba?

  6. I’m newbie in LINUX
    The command ” # mkdir -p /mnt/win” destroyed the previous records under /mnt/win.
    I’m so sad…

  7. Does deleting the local mount point (rm -r) delete the remote Windows shared folder?

    1. Before deleting any directory, we need to un mount it.
      type df -h see the mounted file systems.
      then unmount the perticular file system
      Example: umount /mnt/win
      Then, you need to delete the directory.
      If you dont unmount and give rm -rf everything in the mounted windows share will be lost.

  8. I’m seeing the same problem. I can get around it by using the -d argument, but that means I don’t get back the return code from the process I started remotely.

    It gives the workaround, but not ideal.

  9. Access Windows dir from Linux

    [[email protected] ~]# mount //ipaddress/test /wintest

    [ //ipaddress is a windows system ip and “test” is the windows shared folder name ]

    [ /wintest is the one of linux dir, given full permission ]

    [ “password” is the windows login password ]

      VMWARE-Vclient 5.0.0
      in which i have rhel images…………….

  10. Why my system is not supporting smbfs….?
    i’m getting the error as “mount: unknown filesystem type ‘smbfs’ “

    1. @Raja
      You probably don’t have the filesystem type installed… if you’re using a debian-based system (this should work for Ubuntu), do apt-get search smbfs to find the package name, then apt-get install

      That should fix your problem…

  11. Use the following command to mount windows shared folder into Mac OS X

    To mount:
    mount -t smbfs [email protected]/shared folder /target
    (i.e. mount -t smbfs [email protected]/source /target/)

    To unmount:
    umount /target/

Comments are closed.