SliTaz GNU/Linux official and community documentation wiki.
.png
Translations of this page:

This is an old revision of the document!


What is Samba?

The Samba or SMB suite is a collection of software to enable Windows-style networking on Linux computers. The name Samba is a variation on SMB, short for Server Message Block, which is the file sharing protocol used by Windows machines. The first version of Samba dates from 1992 and a lot of development has been invested over the years. This has resulted in very stable and reliable code. The Samba project also has its own website, www.samba.org where you can do more reading on all aspects of the program.

What can I do with it?

With Samba, your Slitaz machine is able to access file shares which are on Windows servers. Samba is a collection of programs which enable file sharing between Windows and Linux. It is also possible to host a Windows share on your Linux machine, allowing Windows clients to access the files as if they were on a Windows server.

How does it work?

The Samba Suite contains two components. A server implementation (next section) and a client implementation. For example if you have a storage device at home, it will most likely support SMB/CIFS. This means you can use the Samba client to access it from Linux. This is more convenient than ftp or http, especially when you want to use the share for more than just an incidental file copy. With Samba you can access the SMB share as if it were a local disk meaning you can read and write to it, both from the shell, from Perl or with the Graphic File Manager from the Slitaz distribution.

As usual, we use tazpkg to install the Samba client:

# tazpkg -gi smbclient
# tazpkg -gi smbfs

The tazpkg manager will take care of the dependencies so probably you will see a lot more packages being installed. Once this is completed, you can view the shares on your Windows server or storage system with:

# smbclient -L nas
Enter User's password: ****

This will provide a list of the shares available on the machine called nas. Although not strictly required, it is recommended to add the server name to /etc/hosts for name resolution when it has a fixed ip address. Because we are running on Linux we need to 'escape' the backslashes in the UNC path, effectively needing twice the number of them like this:

# smbclient \\\\nas\\share
Enter User's password: ****
smb: \> 

At this prompt you can issue ftp-style commands to browse the file system and read/write files.

Fortunately you can also access a Windows share by mounting it on your box like this:

First create the mount point on your slitaz box: 
# mkdir /nas
#

Then issue the mount command:

# mount.cifs \\\\nas\\share /nas -o user=admin
Password: ******
#

An alternative method is like this:

# mount //nas/share /nas
Password: ******
#

If there is no access-denied-message in reply to the password, it means the share is mounted and can be accesssed from your box. That's basically it!

The password must be the admin password for your storage device. This may not work when you have enabled user-based security. In some cases the mount will be read-only.

Many of the problems with Samba are caused by a lack of understanding the Windows security mechanism. In its basic version, which is still used most of the time, this is user-based security so you will need a valid windows user account to access the file share. When in trouble, verify the access is working from a windows machine and use the same credentials under Linux.

Running a Samba Server on Slitaz

If you need to set up a Windows file server but you don't want to invest in over-the-top hardware and Windows licenses, Samba is the way to go. Of course you can use Slitaz as the Linux platform to run the server. With this solution you will also benefit from the superior stability of the Linux OS. One of the problems of a Samba administrator is that he sometimes forgets the details of his installation because everything simply keeps on running once it has been set up properly. This is one of the reasons why Linux people need documentation anyway. ;-)

To install the server component of Samba, install the following package:

# tazpkg -gi samba

In order to make the user experience even more seamless, it is recommended to keep the accounts synchronized. This means the users should have the same username & password on their windows box as they are using on the Samba server. Explanation: When Windows connects to a share, it always attempts to authenticate using the credentials of the user that requests the access. If there is no match, the user is prompted for a username/password but when they are the same, the share is accessed without any further prompting.

The procedure to add a user to your samba server:

[a] First add Linux user using the adduser command.

[b] Then add the same user name to Samba using: smbpasswd -a

Use: smbpasswd --help to view the options. 

The file shares and printers you want to allow your Windows clients access to can be defined in the Samba configuration file which is: /etc/samba/smb.conf

There are countless options to configure here like login scripts, home folders etcetera. Elaborating on all of them would be way beyond the scope of this guide.

A good place to start is http://www.tldp.org/HOWTO/SMB-HOWTO-2.html which provides a comprehensive overview of Samba but there are many other sites on the web with virtually the same content. As Samba has been around for over two decades, almost all things have already been tried, done and extensively documented in the process. Just search the web. You may encounter some negative comments as well but these are generally posted by people who made some basic mistake or have been the victim of some undocumented change in Windows. Don't let yourself be discouraged by this. Samba is Alive and Kicking and when you know how to search for them, you can be sure to find detailed answers to all issues you may encounter while setting up your own server.

 
en/guides/samba.1367174671.txt.gz · Last modified: 2013/04/28 20:44 (external edit)