Configure IT Quick: An introduction to Samba for the Windows administrator

Walks you through some of the initial setup configurations of Samba and shows you how to test a connection from Windows to Linux or vice versa

Unless you've been trapped in a time bubble and have recently emerged from the 1980s, you're no doubt aware that Linux has now positioned itself as a competitor to Microsoft's desktop domination and as a replacement for the farms of servers that many large organizations have. With Samba, Linux hopes to help displace Microsoft by first embracing Microsoft Windows-based clients and servers by allowing Linux to use Windows files and printers. This is a page from Microsoft's own handbook from when it embraced Novell, only to displace it later.

What's Samba?
Samba isn't a new player in the market. It has been around since 1992. As with most open source software, each year it gets more feature-rich and becomes more stable. Samba has evolved to a point where it's a real option for those system administrators who want to consider moving their file and print solutions to Linux.

It's also a great way to build up storage solutions cheaply. Install a supported IDE RAID card in a box, install Linux, turn on Samba, and you have a great low-cost way to put large amounts of storage on the network. This is ideal for backups of your traveling professionals' notebooks and any long-term archive needs that an organization might have.

Server Message Block
Before installing Samba, it's important to understand a bit about how Samba works. Samba works because it mimics the core Windows file and print sharing protocol, called Server Message Block (SMB). SMB has been around since before Windows. It originated back in the 1980s with Intel, Microsoft, IBM, Xerox, and 3Com. Although it's been extended over the last 20 years, the basic foundations remain the same.

Microsoft has started calling SMB the Common Internet File System (CIFS). This is in part due to a need to distance itself from SMB's humble beginnings riding on top of NetBIOS. NetBIOS was a great tool for its time, but its age is showing in its inability to cope with the sheer number of computers connected on an internal network, or on the Internet itself.

Samba has implemented a version of SMB (or CIFS, if you prefer) that is largely compatible with most versions of Windows. Occasionally, Microsoft throws a curve ball at Samba and causes it to break, as was the case in the Windows 2000 Service Pack when the allowable authentication methods were changed in such a way that Samba was broken. The only way to get Samba working again was through a registry hack to turn an authentication method back on. Despite these small bumps, which can be expected whenever a large integration is being done, Samba is a stable answer to file and print services both to and from Windows machines.

Author's note
For the purposes of this article, I'll be discussing the version of Samba that comes with Red Hat 9.0. Don't let that fact concern you too much. Samba is essentially the same no matter what distribution or version of Linux you're running, although some of the details of what you should do may vary.

Installing SAMBA
Updates to Samba have been released since the release of RedHat 9. Because of that, you will want to download the available updates from RedHat. Check out Red Hat's Samba update page here.

Once you have the updates, you can install them by issuing the following command:
rpm -ivh samba-2.2.7a-8.9.0.i386.rpm samba-common-2.2.7a-8.9.0.i386.rpm samba-client-2.2.7a-8.9.0.i386.rpm samba-swat-2.2.7a-8.9.0.i386.rpm

This will install all the pieces of Samba, including a configuration tool called swat. While I won't use swat in this article, you should note that it's a useful tool that can help you configure the more complex options in Samba.

Basic Samba configuration
The file that controls Samba's setup is located in the /etc/samba directory and is named smb.conf. There is a basic edit that you'll have to make to this file to get Samba working.

You must change the Hosts Allow line to include your local network. If you don't edit this line, then no one will be allowed access to your system. The line should include the prefix for your local network. For instance, my lab network runs on I could put 10. or 10.254. or 10.254.1 in the host allow line to allow all machines on my network to use Samba. Of course, the less specific I make the network address, the more opportunity there is for others to use my Samba server as well.

The final step in making sure Samba is running correctly is to set up a password for at least one user account. Because of the differences between Linux and Windows in the way that passwords are stored, you need to use a utility for the password database for SMB. You can do so by typing smbpasswd -a root at the console prompt.

The utility will prompt you to enter the password and then confirm the password for the selected user—in this case, root. Once this process has been completed, the root user will be able to connect from a Windows machine to the default shares that Samba has in its configuration files. The home directory of the user—in this case, the root user—and a selection of installed printers will become available.

Testing a connection to Linux from Windows
The quickest way to test a connection to your Samba-enabled Linux system is to go to a Windows machine on the same network. Click Start | Run. In the run box, type two backslashes followed by the IP address of your Samba server. Using the IP address eliminates the possibility of name resolution problems on your network. If you prefer, you can test with the name, but note that this method may not work.

You should be prompted for a username and password. Enter the username of root and the password that you typed above. You should see a folder containing a folder named Root and a folder named Printers. The Printers folder will appear even if you have no printers installed on your Samba server.

If you aren't prompted for a username and password, it probably means that Samba hasn't started on your Linux machine. You can check to make sure that the smbd process is running by typing ps -ea | grep smbd at the command prompt. If nothing is returned, Samba didn't start for some reason. You can go to the /var/log/samba directory and review the log files that were created for clues to the problem.

Testing a connection to Windows from Linux
Making a connection to a Windows machine from Linux is similarly easy. The first step is to make sure that you have created a mount point to mount the network share to. For instance, I use /mnt/smb for testing. You can create this directory by using mkdir /mnt/smb when logged in as root and from the root of the drive.

Once you have the directory created, you can issue the mount command to mount the share. There are three key things that you have to be aware of with the mount command and Samba. First, the file system type is smbfs. This means that you must specify -t smbfs on the mount command line. Second, the username on the remote machine is likely not to be the same as on your local machine, so a username must be specified. You can do so using:
-o username=domain\\user

Note that there are two backslashes in the username to separate the domain from the user. This is because of the way the command shell interprets a backslash.

Finally, Windows typically uses backslashes in the UNC path for a share. Because of the translation issues with the backslash in a UNIX command shell, the mount command uses forward slashes. So the final command might look something like this:
mount /mnt/smb //server/share –t smbfs –o username=MYDOMAIN\\Administrator

You'll be prompted for your password, and once you've successfully entered it, you'll be able to access the files on the remote share from the mount point that you've defined, in this case /mnt/smb.

Future direction
Samba's support isn't without its limitations. Right now Samba plays well with Windows 2000 and Windows XP clients, but it hasn't been fully integrated into Microsoft's Active Directory structure. That's what version 3.0 is supposed to bring about. That version is still under development at the time of this writing, although public beta testing is available.

The real goal of Samba is to help simplify one of the challenges with a mixed operating system environment. The challenges of file and print access are not trivial for a large organization, and Samba aims to rectify that.

Editor's Picks