Introduction to Samba for Computer Networks

Samba is client/server technology that implements network resource sharing across operating systems. With Samba, files and printers can be shared across Windows, Mac and Linux/UNIX clients.

Samba's core functionality derives from its implementation of the Server Message Block (SMB) protocol. SMB client- and server-side support comes bundled with all modern versions of Microsoft Windows, Linux distributions, and Apple Mac OSX. The free open software can also be obtained from samba.org. Due to technical differences among these operating systems, the technology is fairly sophisticated.

What Samba Can Do for You

Samba can be utilized in several different ways. On an intranet or other private networks, for example, Samba applications can transfer files between a Linux server and Windows or Mac clients (or vice versa). Anyone using Web servers running Apache and Linux may consider using Samba rather than FTP to manage Web site content remotely. Besides simple transfers, SMB clients can also perform remote file updates.

How to Use Samba From Windows and Linux Clients

Windows users often map drives to share files between computers. With Samba services running on a Linux or Unix server, Windows users may take advantage of the same facilities to access those files or printers. Unix shares can be reached from Windows clients through the operating system browsers like Windows Explorer, Network Neighborhood, and Edge.

Sharing data in the opposite direction works similarly. The Unix program smbclient supports browsing and connecting to Windows shares. For example, to connect to C$ on a Windows computer named louiswu, type the following at the Unix command prompt

smbclient \\\\louiswu\\c$ -U username

where username is a valid Windows NT account name. (Samba will prompt for an account password if necessary.)

Samba uses Universal Naming Convention (UNC) paths to refer to network hosts. Because Unix command shells normally interpret backslash characters in a special way, remember to type duplicate backslashes as shown above when working with Samba.

How to Use Samba From Apple Mac Clients

The File Sharing option on the Sharing pane of Mac System Preferences enables you to find Windows and other Samba clients. Mac OSX automatically first tries to reach these clients via SMB and falls back to alternate protocols if Samba isn't functioning.

Requirements to Configure Samba

In Microsoft Windows, SMB services are built into operating system services. The Server network service (available through Control Panel/Network, Services tab) provides SMB server support while the Workstation network service provides SMB client support, Note that SMB also requires TCP/IP in order to function.

On a Unix server, two daemon processes, smbd, and nmbd, supply all Samba functionality. To determine whether Samba is currently running, at the Unix command prompt type

ps ax | grep mbd | more

and verify that both smbd and nmbd appear in the process list.

Start and stop Samba daemons in the normal Unix fashion:

/etc/rc.d/init.d/smb start
/etc/rc.d/init.d/smb stop

Samba supports a configuration file, smb.conf. The Samba model for customizing details such as share names, directory paths, access control, and logging involves editing this text file and then restarting the daemons. A minimal smd.conf (enough to make the Unix server viewable on the network) looks like this

; Minimal /etc/smd.conf
[global]
guest account = netguest
workgroup = NETGROUP

Some Gotchas to Consider

Samba supports an option to encrypt passwords, but this feature can be turned off in some cases. When working with computers connected over insecure networks, realize that the plain text passwords supplied when using smbclient can be easily spotted by a network sniffer.

Name mangling issues can occur when transferring files between Unix and Windows computers. In particular, file names that are in mixed case on the Windows filesystem can become names in all lowercase when copied to the Unix system. Very long filenames may also get truncated to shorter names depending on the filesystems (e.g., old Windows FAT) being used.

Unix and Windows systems implement the end-of-line (EOL) convention for ASCII text files differently. Windows uses a two-character carriage return/linefeed (CRLF) sequence, whereas Unix uses only a single character (the LF). Unlike the Unix mtools package, Samba does not perform EOL conversion during file transfer. Unix text files (such as HTML pages) appear as one very long single line of text when transferred to a Windows computer with Samba.

Conclusion

Samba technology has existed for more than 20 years and continues to be developed with new versions released regularly. Very few software applications have enjoyed such a long useful lifetime. Samba's resiliency testifies to its role as an essential technology when working in heterogeneous networks that include Linux or Unix servers. While Samba will never be a mainstream technology that the average consumer needs to understand, knowledge of SMB and Samba is helpful for IT and business network professionals.

Was this page helpful?