Once you’ve got your Samba server up and running, you can access it via Windows and Linux. This section shows you how to access the Samba server and also how to use your Samba server to create backups of important datafiles on client systems.
SMB clients are also available for most popular operating systems, including OS/2 and Mac OS (including Mac OS X). You shouldn’t expect to have trouble getting them to work with Samba. If your client seems not to work, simply follow the procedure given in the troubleshooting section.
Windows 3.11, 9x
, Me,
and NT—including Windows 2000, which is an updated release of
Windows NT—have built-in support for the SMB protocol, so
systems running these operating systems can easily access your Samba
server’s resources. Under Windows 9x
/NT,
you can access Samba resources by using the Windows Explorer. Log on
using a user account that’s authorized to access Samba
resources, then click Network Neighborhood, and you should see a
subtree that corresponds to your workgroup. Click that subtree, and
you should see a subtree that corresponds to your Samba server. By
expanding the subtree, you can see the browseable file and printer
shares that are available. You can easily drag and drop files to and
from a shared directory, assuming your user account is permitted the
necessary access.
To use a shared printer, click Start → Settings → Printers
and then double-click Add Printer. The wizard will guide you through
the setup procedure. Simply choose the Network Printer option and
browse to select the desired printer. If you configured the printer
share without the browseable option, you cannot browse and therefore
must type the name of the printer share. To do so, type two backward
slashes, followed by the name of your Samba server, followed by a
single backslash, followed by the name of the printer share. For
example, if you want to access a printer share named
lp
on the Samba server known as
SERVER
, you’d type
\SERVERlp
.
You can map a file share to a drive letter by using the Tools →
Map Network Drive menu item of the Windows Explorer. Simply select an
available drive letter and type the name of the file share, which
consists of two backward slashes, followed by the name of your Samba
server, followed by a single backslash, followed by the name of the
file share. For example, if you want to access a file share named
db
on the Samba server known as
SERVER
, you’d type
\SERVERdb
.
If you have difficulty connecting to your Samba server, follow the procedure given in the preceding section on troubleshooting.
The Samba package includes a simple SMB client that can access your Samba server and other SMB servers accessible to your system. To demonstrate that your client and server are working, log on using a user account that has Samba authorization and issue the following command:
smbclient -L localhost
You should see a list of the browseable shares available on your server. To query a different SMB server, issue the following command:
smbclient -L
server
where server
is the name of the SMB server you
want to contact. Rather than logging on using an authorized user
account, you can explicitly specify a user account by using this
command form:
smbclient -L
server
-U
userid
To actually access resources via SMB, use the following command form:
smbclient
service
-U
userid
where service
specifies the name of the SMB host
and share and userid
specifies the user account
to be used. The name of the SMB host should be preceded by two
backward slashes and followed by one backward slash, for example:
smbclient \servermyshare -U mccartyb
If the SMB server accepts your request, the client displays a special prompt:
smb: dir
>
where dir
indicates the current working
directory on the SMB server. To download a file from the server,
issue the command:
get
file
where file
specifies the name of the file to be
downloaded. To upload a file to the server, issue the command:
put
file
where file
specifies the name of the file. To
list the contents of the current directory, issue the command:
dir
To enter a subdirectory, issue the following command, where
dir
specifies the name of the subdirectory:
cd
dir
You can return to the parent directory by issuing the command:
cd ..
To exit the SMB client, issue the command exit. You can obtain a list of commands by issuing the command help or obtain help on a particular command by issuing the command:
help
command:
where command
specifies the command that you
need help with.
If SWAT fails to suit your taste, several other utilities are available:
Available at ftp://rpmfind.net/linux/dld/5.4/i386/RPMS/i386//ksamba-0.3.3-1.i386.rpm, KSamba is a Samba client for use with KDE.
Red Hat provides the GNOME tools GnoSamba, which you can find at ftp://ftp.redhat.com/pub/redhat/redhat-7.1-en/powertools/i386/RedHat/RPMS/GnoSamba-0.3.3-11.i386.rpm, and Gnomba, which you can find at ftp://ftp.redhat.com/pub/redhat/redhat-7.1-en/powertools/i386/RedHat/RPMS/gnomba-0.6.2-4.i386.rpm.
You can use the smbprint
script included in the
Samba package to print Linux files by using a printer share. However,
you’ll probably have to do some tweaking of configuration files
and adjusting of shell scripts to get smbprint
to work.
One of the more practical uses of the
Linux SMB client is creating backup copies of files stored on a
Windows system. To do so, simply share the drive or directory
containing the files you want to back up. Using the Windows Explorer,
right-click the drive or directory, click Properties, click the
Sharing tab, and select the desired share options. Then, access the
share from Linux using smbclient
. Once you have
the SMB prompt, move to the directory you want to back up and issue
the SMB tar command:
smb: > tar c backup.tar
The syntax of the SMB tar command
resembles that of the tar command,
though it supports only a handful of options. When you issue the SMB
tar command with the c option, the files of the current directory
and all its subdirectories will be backed up and stored in the file
backup.tar
on your Linux system. Of course, you
can specify a filename other than backup.tar
if
you wish (although the .tar
extension is
required). Once you’ve created the backup file, you can write
it to a tape, a writable CD-ROM, or other media. If your backup
requirements are meager, it may be sufficient merely to have a copy
of the file on both your Windows and Linux systems.
To restore a backup, move to the directory where you want the files restored and issue the SMB tar command:
smb: > tar x backup.tar
The SMB client restores each file from the backup.tar
file. Of course, you must have write access to the shared
directory in order to be able to restore files.