Ubuntu – Manually share a folder using Samba, quickly

UPDATE: Modern distros need to run

sudo apt-get install cifs-utils

Or for older systems:

sudo apt-get install smbfs

For some reason, the folder sharing wizard in Ubuntu seldom seems to work correctly for me. So I always end up doing things manually.

In short, this is a three-step process.

  • First we will define what folder(s) to share.
  • Second we will create a password for you to access these folder(s).
  • Third we will mount the Samba share on the other computer, like a disk.

Below is the template for a minimal Samba configuration (/etc/samba/smb.conf), which is where we define what folders we wish to share. You probably have a smb.conf file already in that location; it’s full of stuff we don’t need. Do:

sudo mv /etc/samba/smb.conf /etc/samba/smb.conf.backup

This will backup your original file to the same directory. Then do:

sudo gedit /etc/samba/smb.conf

This will open the text editor for you so we can replace that file with the two blocks below.

Anything in bold should be changed to fit your own needs.


workgroup = MSHOME
netbios name = MOSKAU
comment = Media Server
unix extensions = no

path = /var/tmp/stuff
browseable = yes
comment = Fun Stuff Folder
write ok = yes


  • “Workgroup” is going to be the name of the workgroup your Windows computers are situated on. By default, Windows assumes MSHOME. If you aren’t sharing with Windows computers then this is probably irrelevant.
  • “NetBIOS Name” is the name by which your computer will be identified. Give your Samba host a name; you can set it to be the same as your hostname (cat /etc/hostname to see what yours is).
  • “Unix Extensions” is set to Off in an attempt to stamp out a particular bug I was having at the time I created this configuration file. You might not need it.
  • “Sharename” is going to be the actual name of the share. If you set it to “Moskau” then as far as anybody is concerned the full path to your share will be “//computername/Moskau”.
  • “Path” is the absolute path to the folder you want to share.
  • “Browseable” determines whether a Windows user surfing Network Places can readily see this share. If set to No, then the only way to access the share will be to manually type in the absolute path (i.e. //computername/sharename).
  • “Write OK” allows or disallows the user to make any changes to the contents of the directory over the network.


When that’s done, do:

sudo smbpasswd -a username

Replace username with your username. This will add an entry for username in /etc/samba/smbpasswd and set up a Samba password for yourself. This is different from your login password although you can use the same password if you wish.

Lastly, do:

sudo /etc/init.d/samba restart

Thismay or may not be necessary but I do it anyway. It restarts the Samba daemons and makes sure Samba clears the old file from memory and loads our new one.

From your other computer, make sure WINS has an entry in your /etc/nsswitch.conf, and from the commandline:

sudo mount //hostname/sharename /media/disk -o username=johnny

Obviously there will be some replacement of arguments. //hostname/sharename should be replaced with the hostname and sharename of the Samba host (what we just configured), and /media/disk should be replaced with the location on the other computer at which you want to mount the Samba share (since it gets mounted like any other disk). Username=whatever your username actually is.

When you navigate to your equivalent of /media/disk, you should have access to your remote share.