Sharing Files with Windows using Samba


Unfortunately, Windows can’t connect to NFS, so we have to set up a Samba server. Samba is an open-source implementation of the SMB (Server Message Block) protocol that’s the standard method of file sharing for Windows computers. It allows us to share our unix files and printers to a networked windows computer. It’s actually really simple to set up, as there are not too terribly many options for a windows network.

Installing Samba

We install Samba with apt-get as we have almost everything else so far:

sudo apt-get update && sudo apt-get install dbus samba

once it installs, we can access samba from Webmin. You may have to “Refresh Modules” to get it to show up, but it will be in [Servers → Samba Windows File Sharing]. It should look like this:


Creating Users

Before we can create a File Share, we need to create a couple users to access it, since I doubt you want to give your personal password to anyone wishing to access the file share. We’ll go ahead and do this from the command line as it’s quicker. If you’re only creating the user for use with Samba, then you can just:

sudo useradd -g users -G lp [nameofnewuser] -M

the -M tells useradd not to create a home directory for the user. So if you’re planning on sharing /home so that each user has a separate share, obviously you should leave this off. Note that you don’t need to give this user a system password, since they won’t be logging on the server. We will just give them a samba password later.

If you want your user to have no administrative rights, but otherwise be able to log in to the server normally, run this command:

sudo useradd -g users -G audio,floppy,lp,games -s /bin/bash [nameofnewuser]

and then give them a password by running:

passwd [nameofnewuser]

to give the new user full administrative privileges run:

useradd -m -g users -G audio,lp,video,wheel,games,power -s /bin/bash [nameofnewuser]

and then give them a password as above.

Converting our UNIX Users to Samba Users

From the Samba Page in Webmin (Servers → Samba Windows File Sharing), click on the convert UNIX Users to Samba Users Button. The default settings are fine, so go ahead and click “convert.” It may take a minute to process your users, then you can click “return to shares.”

Now we need to give our new Samba Users passwords. Click on Edit Samba users and passwords. Here you must click on the name of each user you wish to give samba access, select “New Password” and type their password in the field.

At this point our Users are all set up, so we can start creating our samba shares.

Creating a Samba Share

To create a new file share we can go ahead and hit Create a new file share underneath the list of your serves on the Samba Page in Webmin. It will take you to a page that looks like this:

Create a New File Share

From here you can enter your settings:

  • Share Name: This is the name that will appear on the share in your workgroup, so choose something that makes sense: “Media Share” or “Document Share” or something similar.
  • Directory to Share: if you click the “…” button you can browse to the folder you would like to make available.
  • Create with owner: Change this to your username.
  • Create with group: change this to “users”.
  • Share Comment: this is the description that will appear on the file share.

Once you’re done you can hit “Create.” when you get back to the samba screen, click on the name of the Share you just created so we can change a couple settings. In Security and Access Control change Writeable to “yes.” In File Permissions, Change New Unix File Mode to 775 and New Unix Folder Mode to 775. This will make it so that any files or folders created through samba are editable by anyone in the group of the file’s creator, which should be users. When you’re finished, go ahead and return to the main Samba Page and click on Restart Samba Servers to apply the changes.

That’s it. from “Network” in your “My Computer” You should be able to see your Samba Shares and Log-in to them with the credentials we created earlier.