March 24, 2019

Linux Networking: Exploring Samba

The Samba Essentials

  • July 10, 2000
  • By William Wong

Server Message Block (SMB), also known as Common Internet File System (CIFS), is one of the most common protocols for sharing files on a network. It is used with Microsoft Windows and, through Samba, a variety of other operating systems include Linux. Samba provides a way to share the contents of Linux directories with other computers and to access shared directories on a remote computer. The type of remote computer does not matter. It could be a computer running Sun Solaris or Windows NT.

This article assumes that the Linux computer has a network adapter installed as described in the previous section and that the network adapter is assigned a unique IP address. Likewise, the Samba software is installed. With Red Hat and many other Linux distributions, this is done via an rpm package. This can be done when Linux is installed or afterwards. Installing Samba only loads the software and enables the Samba daemon. No sharing will occur until Samba is configured. This article addresses the configuration of Samba as well as issues related to the use of Samba, such as security.

Samba also supports printer sharing. This uses the same SMB protocol as the file sharing support. Samba can be used to provide either or both services.

Samba is an open source project like Apache. Most users will find Samba on their Linux distribution CD-ROM. The latest version of Samba can also be downloaded from the Samba Web site.

Samba Components
Figure 1 shows the Samba components. There are two client applications and one server application. The applications that are used depend upon the type of sharing to be done.

The Samba server application, smbd, is a daemon that runs in the background. It provides access to those directories and printers that are to be shared. Access can be controlled by user name and password.

The two client applications serve different purposes. The smbfs application allows a remote directory to be mounted just as a device like a CD-ROM or hard disk can be mounted in Linux. Any application can then access files on the remote device via this mounted directory. The smbfs application runs as a daemon like the smbd application.

The smbclient is similar in form and function to the ftp application that works with an FTP server like the ftpd daemon on Linux. The difference is that the smbclient works with any SMB server such as smbd or Windows 95 with File And Printer Sharing For Microsoft Networks loaded. The smbclient can only move files to and from an SMB server. It does not allow another application to access these files until they are transferred by smbclient.

Shares, Universal Naming Convention (UNC) And IP Addressing
SMB provides a single level hierarchy of shared resources or "shares" for each computer providing resources to other computers on the network. The computer name and share name are required to access a shared resource.

Share names are essentially the same as directory names. Computer names under Samba can be either a NetBIOS computer name, an IP address, or a domain name that resolves to an IP address. NetBIOS protocol is an underlying part of SMB. Users do not have to be concerned with the underlying details but they will need to know what a computer's name is so its shares can be accessed.

The nmblookup application provides a way to browse the network to discover the names of computers that can be accessed using Samba. The command:

nmblookup *

lists all accessible computers. The nmblookup program has a number of options but these will not be explored here. For small networks, the names of the computers will be known and nmblookup may not be needed.

The nmbd daemon is used to broadcast NetBIOS name information to other computers on the network. The nmbd program will work with a Windows Internet Naming Service (WINS) server that normally runs on a Windows NT computer. In general, small networks can forego configuration of nmbd.

UNC is a naming convention used by Microsoft. It allows a file name to specify the computer that the file is located in addition to any subdirectories. A typical Windows path name looks like \dir1\dir2\filename.txt. A UNC with a computer name and share name looks like \\computer1\share1\dir1\dir2\filename.txt. The UNC name can also be entered with the Samba tools using a slash to separate directory names as in //computer1/share1/dir1/dir2/filename.txt. This will not work on Windows but it can be used to access a Windows-based resource.

Most Popular LinuxPlanet Stories