Install and setup Samba in Linux

What is Samba? If you don’t know what it is then you shouldn’t be reading this 😉 Samba can do a lot of things and we are only cover a basic configuration that will allow you to share specific folders on a Linux machine in the same way you share forlder in a Windows machine.

This will cover a very quick installation and setup of Samba on any Linux flavor, however in this particular case I’ll cover CentOS 5.2

First you need to install Samba’s binaries using yum 🙂 (you can use apt-get or up2date if you want)

Installation stage has been covered, that was fast 😉 Now we need to do a basic configuration in order to start using it and we need to design a structure… let’s say I want to setup a Linux machine to share a specific folder to everyone with read-only access and a specific folder for only local user with read/write access, so here we go:

And paste the following configuration on the new smb.conf

So far we have setup a basic global configuration, a public access area and a restricted area for a local user called “demo”. Before we continue you need to make sure the folder /var/ftp/pub exists. Now, before we start our new Samba server, we need to setup the “demo” account and it can be done in 2 ways:

If we don’t want to give this user shell access, or…

If we want to give this user access to shell and of course we need to set the same password for the system and Samba.
It is time to start our Samba server:

Now let’s try it, on Windows do the following: Start -> Run -> cmd

Hopefully you will see you have 2 new units on your Windows File Explorer, Y which is a read-only folder and Z which is a read/write folder 🙂 that’s all!

If you want to do more things with Samba and you are lazy you can always get Webmin and use its module to configure Samba and use its advanced options.

NOTE: This article is for educational purposes and should be treated as it is.

Troubleshooting:

  • The network name cannot be found: Check your computer’s firewall or if your ADSL/DSL modem, sometimes by default they block all outgoing connections to Netbios port which is 139.
  • Anything else check your log files /var/log/samba/smb.log 🙂

Literature: (Thanks to them, this tutorial exists)
Sunny Walia
Joel Barrios Dueñas
Samba