Ubuntu Home Server – Part 3: Samba File Server Setup

In this part, I am doing a basic setup of Samba as a file server for my clients at home. I want to grant access to the drive to all my local Win* and Linux users.

If samba is not already installed and running, you have to install it first as a prerequisite. Furthermore the smbclient is helpful and will therefore be installed, too.

sudo apt-get install samba smbclient

You can then check the samba status with a

smbclient -L localhost

which will in default configuration lead to an output like that:

Domain=[WORKGROUP] OS=[Unix] Server=[Samba 3.5.4]

Sharename Type Comment
--------- ---- -------
print$ Disk Printer Drivers
IPC$ IPC IPC Service (lithium server (Samba, Ubuntu))
Domain=[WORKGROUP] OS=[Unix] Server=[Samba 3.5.4]

Server Comment
--------- -------
LITHIUM lithium server (Samba, Ubuntu)

Workgroup Master
--------- -------

I want to have one common shared directory (at least at the moment) where all samba users have access to. For this I create an additional group which I call sambausers and I create my users who shall have access to samba and add them to the group. So what I do is:

groupadd sambausers
sudo useradd -m -G sambausers -N -s /bin/false LOGIN

For this users we have to create a samba password which we do with

sudo smbpasswd -a LOGIN

where the -a stands for add user.

The samba configuration file is located under /etc/samba/smb.conf. As next step, I create a backup of the original config file and start with the configuration.

As you can see in one of the first lines in the config file, there is a tool which is called testparm which allows to test if the configuration you did at least is a working configuration and therefore it is said, that it is a good practice to generate the configuration from a smb.conf.master. So we edit the file smb.conf.master and then generate the file smb.conf by executing:

sudo testparm -s smb.conf.master >smb.conf

To test that I rename my smb.conf to smb.conf.master and execute the above mentioned command. This worked and lead to a really small configuration file. But now it is time for me to set it up for my needs.

My basic setup shall be to have a shared drive for all my local users. For that I comment out the printer stuff and append the following to my smb.conf.master:

path = /media/hdd
writeable = true
browseable = true
user = @sambausers
create mask = 0770
directory mask = 0770

You can see the created group here. The user = @sambausers means that all users of that group have access, if you wanted to have a single user(s) you would remove the ‘@’ and write only the user names instead. The create and directory masks are set to 0770 (this is the chmod permission) to allow all users to create files and also edit/delete the files of other users.

Then I restart samba with a

restart smbd

and that’s it.


5 Responses to Ubuntu Home Server – Part 3: Samba File Server Setup

  1. Excellent web site. Lots of useful info here. I’m sending it
    to a few friends ans additionally sharing in delicious.
    And naturally, thanks in your sweat!

  2. If some one wants to be updated with most up-to-date
    technologies therefore he must be pay a quick visit this web site and
    be up to date daily.

  3. I go to see daily a few websites and websites to read content, but this web site provides
    feature based writing.

  4. pravin says:

    Thanks for sharing…..
    its looks good,
    Below link is very easy to understand, just try it.

  5. Pingback: Ubuntu Home Server – Overview « came across

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: