How to install and configure Samba on Ubuntu 14.10

ubuntu samba

Samba is an implementation of services and protocols compatible with SMB (now called CIFS) with which Windows computers communicate with each other: It was developed by Andrew Tridgell through reverse engineering, using Wireshark-style traffic grabbers (formerly known as Ethereal) to offer compatibility in * nix environments, something that was needed to avoid being isolated in corporate and educational environments in which several platforms usually coexist (Windows, Linux, Mac OS X).

Let's see then how to install and configure Samba on Ubuntu 14.10 Utopic Unicorn, ready for offer anonymous shares and also more secure ones in which it is necessary to authenticate to access, in order to offer files to all types of users. And we are going from the base that we have installed Ubuntu 14.10 server, the version of the Canonical distro dedicated to these matters, with a fixed IP address of 192.168.1.100; In addition to this, of course we will need some other equipment in the same local network, and within the same workgroup, to test how everything has been configured.

Install Samba

To begin, we are going to install the Samba packages, something very simple since they are part of the official repositories:

# apt-get install samba samba-common python-glade2 system-config-samba

Configure Samba

configure samba

Now what we will have to do is edit the /etc/samba/smb.conf file, which is the one that carries all the configuration of our Samba server. Prior to this we make a backup of the current file:

# cp /etc/samba.conf /etc/samba/smb.conf.back

Now if we edit the main file:

# nano /etc/samba/smb.conf

We edit the [global] section, which is where we specify the name of the workgroup, the string with which it is identified in the local network, the netbios name, security type and others. We leave it as follows (we can change the first three parameters if we wish):

[global]
workgroup = WORKGROUP
server string = Samba server% v
netbios name = free
security = user
map to guest = bad user
dns-proxy=no

Next we go well down in the file, to the section that says 'Share Definitions' and that starts with [Anonymous]. There we add (of course, we can change the path to the folder that we are going to share):

[Anonymous]
path = / samba / anonymous
browsable = yes
writable = yes
guest ok = yes
read only = no

Now we restart the samba server:

# service smbd restart

A couple of aspects to consider are the fact that the folder that we are going to offer for anonymous access must exist in our file system and must also be accessible to all users, that is, when listing it with:

Ls -l

It should show us read and execute permissions for everyone, that is drwxr-xr-x, or 755 in numerical jargon. If this is not the case we must make it so (we change 'folder to share' by the name and path that we want):

# chmod -R 0755 / sharefolder

Once we have configured the anonymous access let's do the same with him password restricted access, and this is something that takes a little more work, so let's get started. First of all, since in the general configuration we established that security is through user, this means that to access the protected folders we will have to do it using the username and password that exists on the server Ubuntu 14.10 Utopic Unicorn, and therefore we will have to create that account (we can use the name we want, instead of usersamba as we have done):

# useradd usersamba -G sambashare

We enter the user's password when prompted, and then add the samba password:

# smbpasswd -a usersamba

We will also be asked to enter the password twice, after which the user we have created will already have their Samba password. Now we must add the configuration options to share a password protected folder, so we reopen the Samba configuration file for editing.

# nano /etc/samba/smb.conf

We add:

[safe access]
path = / home / samba / shared
valid users = @sambashare
guest ok = no
writable = yes
browseable = yes

The folder / home / samba / shared must have read, write and execute access for the entire sambashare group, so for this we are going to execute:

# chmod -R 0770 / home / samba / shared

#chown -R root: sambashare / home / samba / shared

That's it, we've already been able configure Samband with this we can access this folder from any computer on the local network that is part of the workgroup WORKGROUP, and by doing so we can even save the password for future faster access from Windows, Mac OS X or from other Linux computers.

Video edition
Related article:
Best Free Video Editors for Ubuntu

Leave a Comment

Your email address will not be published. Required fields are marked with *

*

*

  1. Responsible for the data: Miguel Ángel Gatón
  2. Purpose of the data: Control SPAM, comment management.
  3. Legitimation: Your consent
  4. Communication of the data: The data will not be communicated to third parties except by legal obligation.
  5. Data storage: Database hosted by Occentus Networks (EU)
  6. Rights: At any time you can limit, recover and delete your information.

  1.   Ringer said

    Thank you for the contribution, but I think life is complicated a bit, if you put the mouse over a folder with the right button of the same, the option "shared resource in the local network" appears, simply by activating it, ubuntu automatically installs and configures everything what it takes to make it work.

    1.    Willy klew said

      It's true, Bellman

      But we wanted to show how things are done 'by hand', not because we like to complicate ourselves but because the idea is that the process is learned. Thus, if we ever have to do something more complex, such as allowing access to certain users but not others, or allowing read-only access to all and write access to a certain group, we will know how to do it.
      Thanks for comment! Greetings

      1.    luismedina23 said

        That of giving access to some users and others would not be great to learn.

  2.   Avelino De Sousa (@desousavelino) said

    Hi, it's great, your post has helped me, thank you, by the way I have Ubuntu Gnome 14.10 installed and I can't open LibreOffice. Any tutorial or something to solve it? a greeting.

  3.   tron said

    Very well explained ... but it doesn't work for me, it's not because of the tutorial, I don't know why.

    I am with kde and there is no way I see the folders but then I do not have permissions.

  4.   Willy klew said

    Hi tron, what message do you get from the system?

    Have you added the users as users of the sambashare group and also as system users?

    1.    tron said

      Hello Willy thanks for answering.

      I don't know if I'm making a mistake, my intention was to create a user, for example luis and add it to the samba share group and that's it.

      The fault it gives me is lack of permissions.

  5.   Mike silver said

    Hello, could you help me configure a directory of folders in which they must access with user and pass, but one of those users should not enter x folder?

    Excellent tutor!

  6.   yakon79 said

    Sorry, but there is a small error in the following line:

    cp /etc/samba.conf /etc/samba/smb.conf.back, the correct one would be:

    cp /etc/samba/samba.conf /etc/samba/smb.conf.back

    Apart from that, the post is great

  7.   David figueroa said

    Excellent friend, your contribution. I've been trying to give certain users access to this type of shared folder and I can't get an exit.

  8.   iamneox said

    Good afternoon,

    Sorry for the inconvenience but I am not able to create the accesses correctly ...

    I can see the folders when I connect to \\ ip
    but when I want to access the folder with "secure access" I get the message that .. "cannot get access"

    It gives the feeling that I have put the username and password wrong, but no, I have checked it and it is correct.

    Attached screenshot of the message:

    http://gyazo.com/b50a36dfa3b11b726063021a5d830f7b

    Thanks in advance.

  9.   yomopa said

    hello someone help me from ubuntu I see the entire local network and all the computers in it but from a pc with win 7 it does not show the server with ubuntu load on the network all the others but not the ubuntu…. thanks to your prompt reply

  10.   abakuk said

    Hello, good post, I used the graphical interface to install it and everything works. However, when there are electrical problems when starting the server, you have to start the samba services manually and I have not managed to start automatically when starting the system.

  11.   aa said

    it does not work

  12.   makenciee said

    mmmmmmmmmmmmmmmmmm how interesting I want to put it on when it just turns on

  13.   Anonymous said

    It does not come out, there are several things that are wrong in the tutorial, some names are mixed and the permissions cannot be

  14.   Dark said

    The post is good although you would have to update it for Ubuntu 16.04.

  15.   Jorge Mint said

    I agree with Dark. The post is very good but you need to update it to Ubuntu 16.04.
    From already thank you very much.
    Excellent work +10

  16.   samuel said

    Hey I wanted to install a lamp server in ubuntu 16 but when I tried to save databases with my sql it told me a php error, that I did not have the mysql module, after so much research I did not find any concrete solution, so I decided to install my server in Ubuntu 14, I came back here but having everything already installed when I try to open a folder from another machine with windows it sends me an error saying that my credentials probably do not have the permissions and after that error says that access is no longer available, I have been trying to solve that but I just can't, someone help me?

  17.   Friend said

    Thanks to the first one, of course you have to have some common sense as to the correct path of the directory.
    Greetings.

  18.   José Luis said

    Good morning, I congratulate you for the passion that you put into these issues, I am more about electronics than programming, but I like ubuntu because they do it selflessly and with a unique appeal.
    Thanks for his teachings.
    Congratulations on football, I'm a fan of mouth, from Argentina.
    Embrace.

  19.   appliance repair said

    Very useful, this article has been great for me and I can install Samba correctly, greetings.

  20.   Hugo Garcia said

    Excellent guide, he helped me a lot. What I do not understand, is because you have to give permissions 755 to the shared folder but then it is indicated that it must be given permissions 770.
    It worked perfect for me, but that doubt remains.

  21.   Tables said

    Good post. It has worked perfectly for me. I hallucinate with the people who complain as if they were owed something, or the typical Tolosabos of "it's easier with the right button and ...". I would not have the patience to do this for free ... cheer up!

  22.   Abelardo said

    Hello:

    I have followed the steps to share the folders but I cannot see the files inside them from the mac I use to connect to my Ubuntu.

    Thanks for the article that, far from the errors, explains very well the procedure to follow.

    Best regards.

  23.   panchis said

    Good afternoon, I like the idea of ​​installing samba by hand, but I would consider that "by hand" it would be rather from source code, without having to execute apt-get install samba, but, installing all the dependencies and using the commands: ./configure, make and make install would be quite a simple process! Greetings 😀