Setup Samba File Sharing on Linux Mint

By | November 2, 2015

Samba is free software for Linux servers that allows you to share directories and files with Windows workstations, other Linux machines, and smart phones. While the configuration is relatively straightforward, there are quite a few things that can go wrong. This post has the steps you need to get it installed and configured, along with some troubleshooting ideas if it’s not quite working right.

Install Samba

Samba can be installed on your server with a couple commands:

Create Samba User and Group

Next, you will need to create a Samba username and group.

The Samba user will not require shell access to the Linux system, so include –shell /bin/false in the command:

Add the username to the internal Samba database as well:

Create a new group, which all new Samba users will be added to:

Add the newly created Samba user to the Samba group:

Create a Samba Share

You will need to create a directory that will contain the files to be shared. Two possible locations for it are your home directory, or under the /media/ directory.

Use the chown command to make sambagroup the group owner of the new directory.

Configure smb.conf

Edit the smb.conf file, which is located at /etc/samba/smb.conf and add a new share at the bottom with the following options:

The share name can be anything you like. Change the path to match the directory you created earlier. The last line (“valid users”) restricts access to the sambauser user. You can change that to another user, or delete the entire line so that all users have access to the share.

Restart the Samba service so that the changes you made the configuration file are applied:

Test Access

You have successfully setup a Samba share! Now check if the client can access the shared directory. For example, from a Linux workstation:

If a connection is established, type ls to see if you get a directory listing. If it’s not working, read the troubleshooting section further down.

Mount Automatically

This section has been adapted from Ubuntu’s documentation.

To mount the share automatically when the computer starts, add the following line to your /etc/fstab file on the client machine:

//servername/sharename  /media/windowsshare  cifs  username=msusername,password=mspassword,iocharset=utf8,sec=ntlm  0  0

For example:

Then add your Samba login credentials to the file .smbcredentials in your home directory. The contents of the file should look like this:

For security, remove all permissions except those of the owner

Use the mount command to test. The following command will mount all entries in the fstab file:


Access Denied

If you see an error message about access denied, the first thing you should do is check the directory permissions.

Make sure that each directory from the root to the shared folder includes execute permissions for everyone. For example, if the shared directory is located at /media/username/shares/documents you could give all users access to all the directories throughout the path with this command:

To be more restrictive, you can make the samba group an owner of all directories leading to the shared folder and give the group execute permission throughout the entire path.

Samba Log

Check the Samba log for clues as to what the problem may be. The log should be located at: /var/log/samba/log.smbd. You can access it using the tail command. The following command will list the last 50 lines of the Samba log:

Configuration File

To see which options in smb.conf are actually having an effect on the Samba configuration, you can run testparm. You will probably notice that a lot of the settings you typed in the config file are not actually having an effect on the configuration. You can use the output from testparm to cleanup unnecessary statements. It will also tell you if you have entered a setting in the wrong section.


Leave a Reply

Your email address will not be published.