Tuesday, May 27, 2008

Sharing Files and Applications Across UNIX and Windows Machines

Using Samba to Share and Print Files on Different Operating Systems

If you are a Windows user on a network that is constantly connected to a particular UNIX machine, you may need to access or print files that are on the UNIX machine to use in your local applications on your Windows machine. Rather than learn how the UNIX file system works in order to locate and manipulate files, you may want to use an application that allows you to access the files and manipulate them as a Windows user normally does, and have them look just like Windows files to you. The same is true for UNIX users that need to access and print files on a Windows machine.

Samba is an open-source software suite that is available on the web at http://www.samba.org/ through the GNU public license. Mirror sites are available worldwide for both the documentation and the software downloads. Samba was originally developed by Andrew Tridgell but has become a joint project of the Open Source team for Samba. The name Samba is derived from the functionality of the software. The protocol used is the equivalent of what Microsoft refers to as the NetBIOS protocol (also called the Common Internet File System, or CIFS, protocol). This protocol on UNIX is referred to as the Server Message Block (SMB) protocol, hence the name Samba.

One of the things this protocol allows is to mount UNIX file systems so that they appear to be DOS files to a user of a Windows system, or vice versa. A UNIX user can mount a file system on a UNIX machine that is connected to a Windows PC so that it looks like a network drive when a Windows user displays drives under Explorer. For example, you can mount a file system that is called winfiles on a UNIX machine and make it appear as though it is connected as a Windows directory available on the Windows L: drive, appearing as whatever you define it on your Windows machine, say L:\win.

Whenever you perform any file activity on the Windows machine in the directory L:\win, such as creating, modifying, or deleting files, you are actually using the Samba software to perform the activity on the UNIX file called winfiles. The advantage to doing this is that a Windows user does not need to know anything about the file system structure of UNIX to actually manipulate files and directories on a UNIX machine; everything appears as though the environment is Windows. If you are a UNIX user, the same concept is true from the UNIX perspective. Files that are accessed from the Windows machine appear as UNIX files to you.

This approach is different from mounting the remote files via NFS (the Network File System), which is discussed in Chapters 15 and 17. Although the two are functionally equivalent, the NFS approach requires the installation of something called the NFS client, in order to be able to access the files on the UNIX server. On the other hand, NFS is more robust, in that you can have multiple client/server relationships in the same network (for instance, a client can be a server, and vice versa). Which one you use depends on how many Windows clients are on your network. If there are many Windows clients and few UNIX servers, you may prefer the Samba approach. If the opposite is the case, you may prefer to use NFS to share files.

Samba also enables UNIX users to print files on printers connected to Windows-based print servers, and Windows users to print files on printers connected to UNIX-based print servers. While each operating system has its own rules about how to configure printers-for instance, UNIX uses the smb.conf file to configure Samba printers-you can perform essentially the same types of print requests from the other operating system’s print server once Samba is correctly configured.

No comments: