LUX 263 - Linux System Administration III

Lesson 6: Chapter 23, Samba

Objectives:

This lesson discusses Samba services in Linux. Objectives important to this lesson:

  1. Samba
  2. Samba users and passwords
  3. Samba clients
  4. Samba server
  5. Server configuration: smb.conf
Concepts:
Chapter 23

Samba is a collection of programs, like most services in Linux. Some of the programs important to Samba are listed on page 828. Samba's primary goal is to provide access to a Linux network's resources to users who are running other operating systems, such as Windows. We can use a Samba server to provide this access. We can use a Samba client to give Linux users access to resources on a Windows network. At least, we want to. The text provides a URL on page 829 to an online resource called the Unofficial Samba HOWTO. This guide will give you the impression that Samba's goals are hopeless tasks that will sometimes mysteriously deliver on their promises. And sometimes not. If this has put doubt in your mind, you are in the right state to begin.

Pages 828 and 829 show us a list of tools and daemons associated with Samba. Note that there are two daemons in the list.

  • nmbd - Samba requires NetBIOS to work. This daemon is a nameserver for NetBIOS over IP. It provides services to browse remote system resources, called shares. The text tells us that shares are exported directory hierarchies. In other words, they are the part of the other/remote network tree that you are allowed to see.
  • smbd - This is the Samba server. It provides file and print services in both directions: for Linux users on the Windows network and vice versa.

The HOWTO guide tells us that the simple way to start Samba is to load both daemons, after we install and configure the system. The text provides a different approach to loading them, as well as two approaches to configuring the system. This page of minimal setup instructions for a Debian based Samba server may be of use to us.

In the notes on page 829, we are given a list of advice and what seem like random facts about Samba:

  • Samba clients (used by Linux workstations to access Windows resources) expect to use UDP ports 137 and 138. Your firewalls need to allow Samba traffic on these ports.
  • Linux calls granting access to a file share "mounting a directory", but Samba uses the Windows phrase "mapping a share".
  • Samba may use Server Message Block (SMB) or Common Internet File System (CIFS) protocol. SMB is the older protocol, which gives its name to Samba.
  • A Windows user must access Samba with a Windows user name and a Samba password, unless your system is using LDAP or another method for authentication. The user name must match or map to a Linux user name.
  • A Windows user does not need a Samba client to access a share to which rights have been granted. It can be accessed from My Computer or Windows Explorer. In the address line, enter two backslashes, followed by the NetBIOS name of the Samba server. This should provide a display of available shares. Alternatively, you may want to map a drive to the share, which is a more persistent way to gain access. The notation for the mapping is \\servername\sharename.
  • Linux users do not have write permissions when accessing Windows resources through smbclient. They should have an administrator use the mount command instead to add the share like a Linux filesystem. The syntax is
    mount -t cifs //host/share dir
    mount is the command. -t cifs is a required option for the protocol Samba uses. host is the system hosting the share, share is the name of the share, and dir is the pathname of the mount point you will use.

As we have seen in other chapters, the author discusses the topics surrounding Samba at great length, over and over, making it unclear what he is trying to do with his many restarts and his heavy fog of details. A more practical approach to the topic may be found at the Linux.com web site. Another article written as an exercise, clearer than the text, may be found at the Linux Step-by-Step web site. I suggest that we use one of these as a guide to installing Samba on our classroom computers.

The Linux.com article begins like this:

  1. First, install the Samba service with the install command for your version of Linux.
  2. Copy the etc/samba/smb.conf file to a backup location, delete it, then make a new, blank version of it, as we are instructed in the Linux.com article. (Information about this file starts on page 839 in the text.)
  3. If you are not reading the Linux.com article in a browser in Linux, open one and read it there.
  4. Open the new smb.conf file in the LibreOffice equivalent of Word.
  5. Copy the sample smb.conf file from the Linux.com article, paste it into the empty file, and edit it for the circumstances of your network.
  6. Add users to the Samba password file and enable them with the commands
    sudo smbpasswd -L -a USERNAME
    and
    sudo smbpasswd -L -e USERNAME

The Linux Step-by-step article starts like this:

  1. Load Samba
  2. Create a directory to try it out.
  3. Grant permissions to the directory so it can be used
  4. Change to the new directory
  5. Create three files.
  6. Create a user
  7. Create a group

As you can see, the basic steps are similar, and more accessible than the text. Pick one of these as your model for assignment 2 and let's see where it takes us.