Access Windows Shares from Linux

by on November 26, 2006 · 24 comments· LAST UPDATED November 26, 2006

in , ,

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)

TwitterFacebookGoogle+PDF versionFound an error/typo on this page? Help us!

{ 24 comments… read them below or add one }

1 Dan June 17, 2008 at 12:05 am

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:

username=someuser
password=somepass

Reply

2 carpii January 26, 2009 at 11:49 am

The ‘fmask’ and ‘dmask’ smbfs options are deprecated

Use file_mode and dir_mode instead

Reply

3 homer February 23, 2009 at 3:35 am

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

Homer

Reply

4 Alex D June 23, 2009 at 9:34 pm

Would someone be so kind as to explain what the:

auto,gid=users,fmask=0664,dmask=0775,iocharset=iso8859-15

part of the fstab is for.

New to Linux, please assume I’m stupid.

Reply

5 nixCraft June 24, 2009 at 4:57 am

read mount man page, it has all info.
man mount

Reply

6 matt October 5, 2009 at 4:24 am

This helped out a lot. Thanks!

Reply

7 Chingson October 24, 2009 at 10:52 am

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..

Reply

8 Ben January 25, 2010 at 3:23 am

mount -t smbfs didn’t work for me on Fedora 7.
The solution is to use: mount -t cifs

Reply

9 Andrzej May 5, 2010 at 9:49 pm

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?

Reply

10 Anonymous June 24, 2010 at 2:52 pm

Why is there a tweets tab on the side of this page? It is very annoying.

Reply

11 newbie June 28, 2010 at 1:31 pm

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

Reply

12 Linux/Windows Newbie July 7, 2010 at 1:10 am

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

Reply

13 Rajgopal H.Gundgurti July 30, 2010 at 11:05 am

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.

Reply

14 bharath vn October 23, 2010 at 3:56 pm

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.

Reply

15 Robert December 23, 2010 at 3:04 pm

Is it works for me as i am using windows server 2008 and solaris Sun 5.10
Please help me.

Reply

16 PASHA June 14, 2011 at 6:50 pm

Access Windows dir from Linux
==============================

[root@localhost ~]# mount //ipaddress/test /wintest
Password:

[ //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 ]

Reply

17 Gordo May 11, 2012 at 7:41 pm

thanks Pasha, that is awesome and simple

Reply

18 adil January 3, 2013 at 10:23 am

PASHA: YOU MADE MY DAY IT COULD BE THAT SIMPLE I WOUND NT HAVE IMAGINED ……………THANKS AGAIN BRO IT WORKED IN
VMWARE-Vclient 5.0.0
in which i have rhel images…………….

Reply

19 Raja September 12, 2011 at 6:01 am

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

Reply

20 Paul September 19, 2011 at 2:55 pm

@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…

Reply

21 shivakalyan September 24, 2011 at 10:59 am

Raja replace smbfs to cifs. I had the same issue and it worked for me when i use cifs

Reply

22 Elangovan October 4, 2011 at 12:07 pm

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

To mount:
mount -t smbfs //username@sharedIP/shared folder /target
(i.e. mount -t smbfs //administrator@10.1.2.3/source /target/)

To unmount:
umount /target/

Reply

23 Ibrahim June 22, 2012 at 2:20 pm

Hi, I think the best way is to use smb through nautilus
smb://yourmachine/yourfolder
it works with IP address:
smb://[youripaddress]
http://www.cyberciti.biz/tips/browse-a-samba-or-ms-windows-share-in-nautilus.html
I turn off selinux/firewall.

Reply

24 Jordan April 6, 2013 at 5:49 pm

Greate!
Tks!

Reply

Leave a Comment

Tagged as:

Previous Faq:

Next Faq: