Follow Techotopia on Twitter

On-line Guides
All Guides
eBook Store
iOS / Android
Linux for Beginners
Office Productivity
Linux Installation
Linux Security
Linux Utilities
Linux Virtualization
Linux Kernel
System/Network Admin
Programming
Scripting Languages
Development Tools
Web Development
GUI Toolkits/Desktop
Databases
Mail Systems
openSolaris
Eclipse Documentation
Techotopia.com
Virtuatopia.com
Answertopia.com

How To Guides
Virtualization
General System Admin
Linux Security
Linux Filesystems
Web Servers
Graphics & Desktop
PC Hardware
Windows
Problem Solutions
Privacy Policy

  




 

 

10.4 Samba Client Configuration and Use

Once you've got your Samba server up and running, you can access it via Microsoft Windows, Linux, and other operating systems. This section shows you how to do so and also how to use your Samba server to create backups of important data files on client systems.

10.4.1 Microsoft Windows Client

Microsoft Windows 3.11, 9x, and NT have built-in support for the SMB protocol, so systems running these operating systems can easily access your Samba server's resources. Under Microsoft Windows 9x and NT, you can access Samba resources by using the Windows Explorer. Log on using a userid that's authorized to access Samba resources. Then click on Network Neighborhood 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 userid is permitted the necessary access.

To use a shared printer, click on Start -> Settings -> Printers and then double click on Add Printer. The wizard will guide you through the setup procedure. Simply choose the Network Printer option and then 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 backslashes, 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 \\SERVER\lp.

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 backslashes, 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 \\SERVER\db.

If you have difficulty connecting to your Samba server, follow the procedure given in the preceding section on troubleshooting.

10.4.2 Other Clients

Of course, an SMB client is available for Linux; you'll learn about it in the next subsection. SMB clients are also available for most popular operating systems, including IBM OS/2 and Mac OS. 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.

10.4.3 Linux Client

The Samba packages include 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 userid 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 log on using a authorized userid, you can explicitly specify a userid by using this command form:

smbclient -L 
server -U 
userid

To actually access resources via SMB, use the following command form:

smbclient -L 
service -U 
userid

where service specifies the name of the SMB host and share and userid specifies the userid to be used. The name of the SMB host should be preceded by two backslashes and followed by one backslash.

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 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

where file specifies the name of the file. To enter a subdirectory, issue the command:

cd 
dir

where dir specifies the name of the subdirectory. 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 for which you want help.

Ivan Volosuk has written an X11 interface for smbclient, which you may find easier to use. You can learn more about it from his web page, available at https://www.rt.mipt.ru/frtk/ivan/.

You can use 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. This might be a good project for you to tackle after you've read Chapter 13, Conquering the BASH Shell.

10.4.4 Using the Linux Samba Client for File Backup and Recovery

One of the most practical uses of the Linux SMB client is creating backup copies of files stored on a Microsoft Windows system. To do so, simply share the drive or directory containing the files you want to backup: using the Windows Explorer, right click on the drive or directory, click on Properties, click on 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 backup, and issue the following SMB command:

tar c backup.tar

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. Once you've created the backup file, you can write it to a tape, a writable CD-ROM, or other media, if you need an offsite copy. If your backup requirements are meager, it may be sufficient merely to have a copy of the file on both your Windows system and your Linux system.

To restore a backup, move to the directory to which you want the files restored and issue the following SMB command:

tar x backup.tar

The SMB client restores each file from the tar file. Of course, you must have write access to the shared directory in order to be able to write the restored files.


Previous: 10.3 Samba Learning Debian GNU/Linux Next: 11. Getting Connected to the Internet
10.3 Samba Book Index 11. Getting Connected to the Internet

 
 
  Published under the terms of the Creative Commons License Design by Interspire