In this article, learn about these concepts:
- Features of Windows clients
- Using browse lists from Windows
- Creating file and printer shares in Windows
- Using the Windows
This article helps you prepare for Objective 314.4 in Topic 314 of the Linux Professional Institute's (LPI) Mixed Environment specialty exam (302). The objective has a weight of 4.
To get the most from the articles in this series, you should have an advanced knowledge of Linux and a working Linux system on which you can practice the commands covered in this article. In particular, you should have a working knowledge of Linux command-line functions and understand the basics of Samba configuration. You should be able to boot and use a Windows computer and be familiar with its basic operations, including its Command Prompt window. This article uses Windows 7 clients in its examples, but the procedures and principles are similar in earlier versions of the operating system.
Setting SMB/CIFS options in Windows
Just as you must configure Samba with certain basic information, such as your workgroup or domain name, you must also configure Windows with this information before you begin accessing Samba shares. To do so in Windows, perform these steps:
- In Control Panel, click System and Security, and then
The result should resemble Figure 1, which includes information on the computer's name and its workgroup or domain name near the bottom of the window.
Figure 1. The Windows Control Panel gives you access to system naming options
- Click Change settings in the Computer name,
domain, and workgroup settings area.
Doing so produces the System Properties dialog box, shown in Figure 2. You can use this dialog box to change the computer's network basic input/output system (NetBIOS) name and its domain or workgroup affiliation.
Figure 2. The System Properties dialog box provides access to naming options
- Change the Computer description field to show something informative, as suggested by the prompt below that field.
- If the computer's NetBIOS name (shown in the Full computer name
field) and workgroup or domain name are correct, click OK.
Otherwise, click Change to set the NetBIOS name and
workgroup or domain affiliation.
When you click Change, the Computer Name/Domain Changes dialog box shown in Figure 3 appears.
Figure 3. You can set the computer's name and domain or workgroup affiliation in the Computer Name/Domain Changes dialog box
- Type the computer's NetBIOS name in the Computer name
This entry is particularly important if you want to share directories or printers on this computer; it's less important if the computer will function only as a client. It affects NetBIOS naming only.
- If you like, you can change the computer's Domain Name System (DNS) host
name by clicking More beneath Full computer name.
Note that any change you make will be local; it affects the way the computer identifies itself to other computers but won't affect the name other computers use to identify the one you're configuring. If you want to change the computer's DNS host name, you must adjust your network's DNS server.
- Select the Domain or Workgroup option,
as appropriate, and type your local domain or workgroup name in the
Note that the Domain option is grayed out on some versions of Windows, such as Windows 7 Home Premium. If you want to fully join a domain, you must upgrade your version of Windows.
- When you've made all your changes, click OK.
Windows informs you that it must reboot. You may also have to enter authentication information if you're attempting to join a domain. See the article "Learn Linux, 302 (Mixed environments): Domain control" for more information on this topic.
After you have rebooted, Windows should use its new NetBIOS name and workgroup or domain identity, and the procedures described in the rest of this article should work. If they don't, review your configuration: There might be a typo in the domain or workgroup name. There could also be a more fundamental problem, such as a loose network cable.
Accessing files from Windows
Ideally, your Samba server's configuration works with little or no fuss from your Windows clients—in fact, this is often the case. Thus, this article begins with the assumption that everything works fine. Working from this assumption, I describe how to browse to a Samba share in Windows and how to directly enter a Universal Resource Identifier (URI) for a share in Windows. If you have problems, the upcoming section, Debugging problems using a Linux client, may be helpful.
Browsing to a Samba share
As described in the article "Learn Linux, 302 (Mixed environments): File services," Server Message Block (SMB)/Common Internet File System (CIFS) provides features designed to simplify locating file and printer shares on a network. The details of how this is done depend on the client's user interface (UI), and in fact there are several ways to browse for shares in Windows. One is to use the operating system's integrated file manager:
- Open Windows Explorer by right-clicking the Computer desktop
icon, and then clicking Explore, as shown in Figure 4.
Figure 4. File browsing is tightly integrated into Windows Explorer
In the left pane, the Network item provides access to network browse lists. Click a computer's name to see the shares it provides in the details pane, click those shares to open them, and so on.
- When you've opened a share and located a file, double-click it to open it in a suitable application, drag it to the Recycle Bin to delete it, and otherwise treat it much as you would a file on your local hard disk.
Similar features are available in the Windows Open and Save As dialog boxes that many programs use to enable you to locate files.
Entering a URI
Sometimes, browsing doesn't work correctly. Your network may be experiencing browsing difficulties, or you might have deliberately configured a share not to appear in browse lists. If this is the case and you know the exact DNS or NetBIOS name of the server as well as the name of the share, you can enter the URI for the share directly in Windows Explorer. To do so, complete these steps:
- Click in the address bar.
Be sure to click to the right of the existing entries: You don't want to select one of them. The field should change to show the entry in URI form.
- Type the exact path to the share you want to access in the form \\COMPUTER_NAME\SHARE_NAME\, such as \\NESSUS\RODSMITH\ to access the RODSMITH share on the NESSUS computer. Press Enter when you've completed your entry.
Windows Explorer should now show the contents of the share you've specified. You should be able to manipulate files and folders as if you had browsed there directly.
Mapping network shares
Sometimes, it's convenient to assign a network share a drive letter so that it can be accessed more simply than by entering a URI or browsing to the share. In Figure 4, the \\NESSUS\RODSMITH share is shown already mapped to drive N.
To create a new drive mapping, browse to a share, right-click it, and then click Map Network Drive. The Map Network Drive dialog box, shown in Figure 5, appears. You can set the drive letter and select various other options to fine-tune the results.
Figure 5. Mapping a network drive assigns it a drive letter in Windows.
Printing to Samba from Windows
Assuming that your Samba printer configuration is appropriate, printing to Samba from Windows can be straightforward. The basic process involves creating a printer queue in Windows and linking it to the appropriate Samba share. The biggest complication is likely to be deciding which driver to use, because some Samba shares require you to use a native Windows driver, others require you to use an unrelated PostScript driver, and some enable you to use either type of driver.
Setting up a printer
To create a printer queue in Windows, complete these steps:
- Open the Control Panel's Hardware and Sound item, and then click
Add a Printer.
A dialog box appears asking what type of printer you want to add.
- Select Add a Network, Wireless or Bluetooth Printer.
Windows searches for available printers and displays a list similar to the one shown in Figure 6.
Figure 6. Windows detects network printers and displays them in a list
- Select the printer you want to use, and click Next.
If you don't see your printer, you may need to reconfigure its Samba share. If you've deliberately hidden the printer from browsing, though, you can click The printer that I want isn't listed to provide a URI for the printer.
- If you've configured the server that hosts the share to deliver drivers, Windows should automatically download and install them. If not, you'll see a dialog box stating that a driver could not be found. You must then select a driver from a list of standard Windows drivers or install one provided by the printer manufacturer.
- When the driver is installed, print a test page.
When the printer is configured correctly, you can select it from any application's Print dialog box, as shown in Figure 7.
Figure 7. Use a configured printer by selecting it from the Name list in the Windows Print dialog box
Deciding which driver to use
Because Linux uses PostScript as a standard printer input and converts this input to the printer's native language for non-PostScript printers, it's generally possible to treat all Samba printers as if they were PostScript models. To do this, you must install a suitable generic PostScript driver in Windows, either by selecting it in the Windows client or by using Samba to deliver the driver. Among the standard Windows printer drivers, the Microsoft Publisher Color Printer driver in the Generic section usually works well for Samba printers.
Instead of using a PostScript driver, however, you might prefer to install a printer-specific driver provided by the printer's manufacturer. Doing so requires that you track down that driver, and you may also need to configure Samba or Common UNIX® Printing System (CUPS) to handle the raw data feed appropriately rather than trying to interpret it and convert it to the printer's native language, as CUPS generally does.
Broadly speaking, several factors differentiate PostScript from native drivers:
- Using a PostScript printer driver for a non-PostScript model has the disadvantage that you may not get proper access to all of a printer's unique features, such as tray selection and resolution settings. Such features are usually accessible from native printer drivers.
- Using a PostScript driver can reduce network bandwidth consumed by print jobs of textual material compared to printing the same text-heavy documents using native printer drivers. This effect is most notable on inexpensive inkjet printers rather than mid-range to high-end laser printers.
- Using a PostScript driver increases the CPU demands on the print server computer. This effect is likely unimportant unless the server is underpowered by modern standards or handles many printers.
- Using a native driver can require reconfiguring Samba or CUPS, which is sometimes more hassle than it's worth.
You can try multiple drivers, if you like, to see which one works best on your network and with your printers. In some cases, you might want to create multiple Samba queues for a single printer and link each to a different Windows driver. That way, users can select the driver that works best for particular print jobs.
Using the Windows net command
Although Windows use and administration is much more graphical UI (GUI) oriented than Linux,
there are text-mode Windows utilities, and some of them have advantages over their GUI
counterparts. For SMB/CIFS, the principal text-mode tool in Windows is
net, which can perform many of the tasks you can perform
using the GUI. The
net command has an advantage, however,
in that it can be scripted, so you can use it in a network startup script to perform a
common set of tasks on all computers or to perform a complex set of actions with a
net, you type the command followed by a subcommand
name, some of which require additional options. Table 1
summarizes the most important
Table 1. Subcommands of the Windows net command
|Displays or updates various network settings, such as the computer's NetBIOS name and workgroup or domain name|
|When typed on a Windows file server, displays information on shared files opened by clients|
|Displays help information for the use of the |
|When typed on a Windows file server, displays active connections from clients; adding
|Displays statistics on sent and received bytes, errors, and so on associated with client
|Sets the computer's clock to match that of another computer|
|Maps a share to a Windows drive letter or displays information on current mappings|
|Adds, deletes, or modifies a user account stored on a domain controller|
|Displays a list of computers on a network or of shares available on a given computer|
You can use several of these options to produce an effect similar to those you can achieve
in a file browser. Specifically, you can use
USE to browse for file shares, as
Listing 1 shows.
Listing 1. Browsing file shares using the VIEW command
> NET VIEW Server Name Remark ------------------------------------------------------------------------------- \\NESSUS Nessus \\SEEKER seeker server (Samba, Ubuntu) \\VBOX7 VBox7 \\WEMBLETH Wembleth The command completed successfully. > NET VIEW \NESSUS Shared resources at \\NESSUS Nessus Share name Type Used as Comment ------------------------------------------------------------------------------- cf Disk Epson RX500 CF port floppy Disk Floppy Drive hp4000 Print HP4000 via Ethernet rodsmith Disk Home Directories smbpdf Print PDF Generator Stylus_Photo_RX500 Print EPSON Stylus Photo RX500 The command completed successfully. > NET USE \\NESSUS\cf I: The command completed successfully.
This example shows the process of browsing the network and mapping the \\NESSUS\cf share to the Windows device at drive I:. Thereafter, the device can be accessed using that device name.
NET TIME command can be a quick substitute for a
Network Time Protocol (NTP) server. The following command synchronizes the Windows
computer's clock to that of the NESSUS server:
> NET TIME \\NESSUS /SET
Bear in mind that some of the
net subcommands require
Administrator privileges. If you try to use these commands without first opening an
Administrator command prompt, the utility reports that you lack sufficient privileges.
In the case of
USER, you may need to know a password for
altering the account on the remote computer, too.
Using Windows as a server
Although the focus of the LPIC-302 certification—and therefore of this article series—is on using Linux as a Samba server, it would be misleading to suggest that the combination of Linux and Samba is the only one that can perform SMB/CIFS server duties. The protocol, after all, originated as a way for DOS, Windows, and IBM® Operating System/2® (OS/2) computers to share resources; Samba entered the picture years later. Thus, I briefly describe the process of sharing files and printers from Windows for use by Windows or Linux clients.
Sharing files from Windows
You can configure a Windows server to share an entire partition or just a subdirectory of it, such as your user directory or a subdirectory of it. To do so, complete these steps:
- Browse to the drive or directory you want to share.
- Right-click the drive or directory, and then point to Share with, which has a submenu with various options.
- Select an option from the Share with command.
Windows 7 incorporate a feature known as a Homegroup, which enables sharing with a predefined set of users. If you haven't set up such a group or if you want to specify some other group, click Specific People. Selecting this option produces the dialog box shown in Figure 8.
Figure 8. Windows enables you to specify with whom you want to share your files
- Select a user or group from the Add list, or type a user name in the box.
- Click Add.
- If desired, adjust the permissions granted to the user you've selected by adjusting the new entry under the Permission Level column.
You can now test the new file share by attempting to connect to it from another Windows or Linux computer.
Sharing printers from Windows
If you want to print to a printer that's physically connected to a Windows computer, you can create a printer share on that server. To do so, complete these steps:
- Install and configure a printer queue for the local printer.
- In the Control Panel's Hardware and Sound item, click Devices and Printers.
- Right-click the printer you want to share, and then click Printer Properties.
- Click Sharing in the Properties dialog
box. The result resembles Figure 9.
Figure 9. You can share a printer in Windows from its Properties dialog box
- Select the Share this printer check box, and type a
name in the Share name field.
The Render print jobs on client computers check box and Additional Drivers button may be important for some Windows clients; but if you want to share the printer so that Linux clients can use it, you needn't be concerned with either option.
- Click OK to finalize your changes.
Linux's CUPS subsystem can create a print queue that prints to an SMB/CIFS printer share, so you can print to a Windows shared printer from Linux. Keep in mind that the shared printer—if it's not a PostScript model—needs Linux drivers; that is, print jobs must be rendered on the Linux side and sent over the network in the printer's native format. This contrasts with printers shared via Samba, which can be handled this way or by sending print jobs in PostScript form.
Debugging problems using a Linux client
You can use a variety of Linux tools to help debug SMB/CIFS networking problems, using
both Samba and Windows servers. Some of these tools have been described in other
articles in this series, so I describe them only briefly here. These tools and techniques
include mounting a share, using
smbclient, and using
smbget. Although it's not really related to Samba or
314.4 also mentions
I describe it here, too.
Test-mounting a share
The most obvious way to test a share is to attempt to use it with common tools.
For a Linux client, this means mounting it with the
cifs file system tools, as described in the
Linux, 302 (Mixed environments): CIFS integration."
(In the past, the
smbumount utilities mentioned in the LPIC objective
314.4 could be used to mount and unmount SMB/CIFS file systems, but support
for these tools was dropped with the 2.6.37 Linux kernel.)
mount //SERVER/SHARE /mnt,
SERVER is the server name and
SHARE is the share name, is the simplest
way to test your ability to mount the share. As described in the Objective 314.1
article, though, you may need to add more options to specify your user name,
password, and so on.
If you can't mount a share, you might find clues in your Samba log files or in the
kernel ring buffer (accessible by typing
could be that you need to adjust your mount options. It's also possible that
problems reside at the server end; you may need to adjust permissions or other
Testing using smbclient
smbclient program, which is described in the article
Linux, 302 (Mixed environments): CIFS integration," can be a good way to test for basic functionality, because it's
a fairly basic tool that provides a direct interface to the server computer without
the complications of file system mappings.
Testing using smbget
smbget program is analogous to
wget, which retrieves files using HTTP. To use
smbget, you must know the precise URI for the file
you want to retrieve. In its simplest form, you type the command followed by
$ smbget smb://WEMBLETH/REPORTS/financial-report.pdf
This example retrieves the file financial-report.pdf from the REPORTS share on the
WEMBLETH server. You can add various options to modify
behavior, such as
-u to specify a user name or
-R to recursively retrieve an entire directory tree.
Consult the program's
man page for details of its
Testing using rdesktop
rdesktop program is a Linux implementation of the Remote
Desktop Protocol (RDP), which is a Windows remote access protocol similar in principle
to the Virtual Network Computing (VNC) tools. You activate RDP in the System
Properties dialog box (shown in Figure 2). Click the
Remote tab, and set an option in the Remote Desktop
area that matches your desired security setting. When you're done, click OK.
Note: Not all versions of Windows support RDP. The Home versions, in particular, lack this feature.
rdesktop, you can type the program's name followed
by the server's DNS host name or IP address. You can also optionally include any of a
large number of options, such as
-u to specify the user
name. Consult the program's
man page for details.
- Rod's article "Learn Linux, 302 (Mixed environments): Print services" (developerWorks, August 2011) describes how to configure Samba as a print server to share printers.
- Rod's article "Learn Linux, 302 (Mixed environments): Domain control" (developerWorks, August 2011) covers configuring Samba as a domain controller.
- Rod's article "Learn Linux, 302 (Mixed environments): CIFS integration" (developerWorks, October 2011) covers Linux's SMB/CIFS client tools.
- Rod's article "Learn Linux, 302 (Mixed environments): NetBIOS and WINS" (developerWorks, November 2011) covers configuring Samba's browsing and NetBIOS features.
documentation on the
netcommand describes this command and its subcommands in detail.
- At the LPIC Program site, find detailed objectives, task lists, and sample questions for the three levels of the LPI's Linux systems administration certification. In particular, look at the LPI-302 detailed objectives.
- Review the entire LPI exam prep series on developerWorks to learn Linux fundamentals and prepare for systems administrator certification based on LPI exam objectives prior to April 2009.
- In the developerWorks Linux zone, find hundreds of how-to articles and tutorials as well as downloads, discussion forums, and a wealth of other resources for Linux developers and administrators.
- Follow developerWorks on Twitter, or subscribe to a feed of Linux tweets on developerWorks.
- Stay current with developerWorks technical events and webcasts focused on a variety of IBM products and IT industry topics.
- Attend a free developerWorks Live! briefing to get up to speed quickly on IBM products and tools as well as IT industry trends.
- Watch developerWorks on-demand demos ranging from product installation and setup demos for beginners to advanced functionality for experienced developers.
- Get involved in the My developerWorks community. Connect with other developerWorks users while exploring the developer-driven blogs, forums, groups, and wikis.
Dig deeper into Linux on developerWorks
Get samples, articles, product docs, and community resources to help build, deploy, and manage your cloud apps.
Experiment with new directions in software development.
Software development in the cloud. Register today to create a project.
Evaluate IBM software and solutions, and transform challenges into opportunities.