How to mount Windows (SMB) shares on Ubuntu Linux

Here's how to mount SMB (Windows) shares on an Ubuntu system. Most of this assumes you're the root user. You may have to prepend 'sudo' to many commands depending on your situation.

First, you may have to install the following :

- # apt-get install smbfs smbclient

You can do a simple interactive connect with this :

- # smbclient \\\\YOUR_SERVER\\myusername-U myusername -W YOUR_WORKGROUP

This will at least show the SMB share is reachable.

Next, to enable auto-mounting on system start, you'll want to add one of the following to your /etc/fstab file :

- //YOURSERVER/sharename /share/sharename smbfs auto,username=myusername,password=SECRET,uid=1000,umask=000,user 0 0

- //YOURSERVER/sharename /share/sharename smbfs auto,credentials=/root/.credentials,uid=1000,umask=000,user 0 0

You'll need to create the directory /share/sharename on your Linux system if you haven't done so already.

The second, credentialed entry above is more secure since everyone can read /etc/fstab.

The file /root/.credentials-smb should have the following :


It also should have these permissions : chmod 600 /root/.credentials-smb

You can see if your SMB share mounts with :

- # mount -vvv /share/sharename (or mount -a -vvv)

The -vvv provides verbose output for debugging.

Here's a great reference on this :



There is 1 Comment

Nice post. though afaik I'd rather use cifs instead of smbfs. cifs is a modern replacement for smbfs:

/YOURSERVER/sharename /share/sharename cifs auto,username=myusername,password=SECRET,uid=1000,umask=000,user 0 0