Folder sharing in Ubuntu using Samba

Samba used to be the unix sysadmin's living nightmare. That's all changed!
Sharing folders across the network from one Ubuntu machine to another, or to and from Windows machines, is really easy.

Here's how you do it... This works on Ubuntu Intrepid and later

On the machine where the folder lives

Navigate to the folder you want to share with Nautilus (the file explorer)

Right-mouse on the folder and click sharing options...

tick share this folder

Now, the very first time you do this, it will say you need to install the Windows networks sharing service.
Click "install service"
Tick the box to over-ride PAM settings (even though it's not at all obvious what that all means)
Then you need to restart your session (log out and log back in again).

You also need to (once only) set your samba password on the machine where the folder lives

At a command prompt type

sudo smbpasswd -a your_user_name
Now put in your password to get sudo privileges
Now put in the password you want to use for network access to your folders (probably not the same as your normal password, but that's up to you!)
Back to the story...

If you want to grant write access as well as read-only access, also tick the next box

You'll also need to know the IP address or dns name of this machine
Use ifconfig or System -> Administration -> Network Tools and select the Network device through which you are connected and read off the IP address

On the machine from which you want to access the shared folder

Places->connect to Server
service type: windows share
server: ip address of remote machine

Enter the samba password that you previously set, when prompted

If you have trouble connecting, make sure the firewall on the remote system isn't blocking you.

sudo service iptables stop
removes all the firewall rules, but will at least allow you to eliminate that from the diagnosis!

From the explorer for the remote system, go into one of the shared directories and copy what you want to an explorer window on the local system.

Note you can't drag a shared folder to copy it and its contents - it says "not a directory".
So you have to open it, select all (ctrl-A), then drag into the new folder.

And there you go!

To stop sharing a folder, right-mouse Sharing Options - untick the share box.

Power User bits

One useful tidbit: if you need to get at the samba-mounted remote directory directly, rather than through Nautilus explorer, you'll find it in the ~/.gvfs/whatever on wherever directory :)

If you know your hostname and share name, you can directly access the samba share from the Nautilus location bar with:


and finally...

don't forget to restart your firewall if you stopped it
sudo service iptables start

comments and updates to: