Access Windows Shares from Linux

by Vivek Gite · 8 comments

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)

Featured Articles:

Want to read Linux tips and tricks, but don't have time to check our blog everyday? Subscribe to our daily email newsletter to make sure you don't miss a single tip/tricks. Subscribe to our weekly newsletter here!

{ 8 comments… read them below or add one }

1 Dan 06.17.08 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

2 carpii 01.26.09 at 11:49 am

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

Use file_mode and dir_mode instead

3 homer 02.23.09 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

4 Alex D 06.23.09 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.

5 Vivek Gite 06.24.09 at 4:57 am

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

6 matt 10.05.09 at 4:24 am

This helped out a lot. Thanks!

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

8 Ben 01.25.10 at 3:23 am

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

Leave a Comment

You can use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>

Previous FAQ:

Next FAQ:

nixCraft FAQ PDF Collection Now Available To All