19 April 2012

The samba tutorial. A learning experience.

DISCLAIMER
The setup proposed in the material should never be used on a deployment system. This is strictly for development purposes. Plus, I can't imagine a good reason to have samba installed on an actual web server.



I hope that my tutorials are as much of a learning experience for the people watching them, as they are for the guy making them (me). Linux is a big universe that you may not know enough about, and maybe you can't know everything about it. There is the core of the OS a.k.a. kernel called Linux, fundamental to the operation of the system yet hidden behind a silent veil of stability. A microcosm in itself whose machinations are reserved for the geekiest of geeks. Above it there is a herd of GNU userspace applications running POSIX (Portable Operating System Interface) compliantly across the endless fields of UNIX. Two parts merged in a multitude of distributions that are a testament of imagination, creations inspired by freedom and driven by the force of human endeavor. All in harmony spreading across the physical and the logical layers of existence itself, connecting not the technological but the pure human network. And you can run samba on it.


Samba is a network service allowing a UNIX or UNIX like system to masquerade (colloquially masquerade(I think)) as a windows system on the network, allowing the sharing of different resources. It is a service that wouldn't have been thought of in a perfect world, but is practically indispensable in ours. If you follow my blog you will know that I am new to Linux (and the unix world), and that my IT career is mainly in windows administration (there is no such thing). So probably the first gap in Linux adoption for me personally was network interoperability. I am trying to help other people see the light, so I will share the required entry knowledge in an attempt to spare you the frustration of tackling this difficult subject on your own. And then just point you in the right direction, so that you may continue your studies. The reason for crossing over were my interests in web development, so we take the point of view of a web developer as we look at samba. We do this in an openSUSE based virtual web/development server that is part of the B.L.H.T. .

We start of with a simple install and a simple setup of samba through YaST. The installation is done in a very YaST way. We initially just install the YaST module that is used to configure samba, and not samba server itself. Then we restart YaST and we enter it's samba configuration, from then on the installation of the actual samba server is handled automagically. The samba-server configuration module is also used to set the server to start at boot, and handles the configuration of the firewall. We delete the default shares (optional), and create a new share that gives write access to the apache document directory.

In the second video we take a brief look at the smb.conf file that was automatically generated by YaST. Then we cover some basic file permissions issues that everybody who configures samba needs to know. Samba at this point is set to allow everybody (and his brother) to read and write to the shared resource. Fortunately for us it's not that easy to make a Linux box insecure, but we manage anyway.Then I just write a very long sentence, whose only purpose is to take up space so that the blog page looks more esthetically pleasing to me, and I don't just freak out because of my OCD nature (unfortunately that just wastes your time and annoys you)!

We end things of by adding a new user to samba by issuing the `smbpasswd -a` command and setting a password for remote access. The thing you really need to grasp is that file permissions do not care for your user or password, the files still have their owner and group. To finally really have a write enabled shared resource, we change the owning group of the /srv/www directory and we give the new group write access. From then on, new files created inside will have their owners correctly set so that the web developer can just mount the shared folder on his system and work with the files as if they were on his system.

For more information about openSUSE and samba, click on them!