Learn Linux, 302 (Mixed environments): Working with Windows clients

Using Windows clients with Samba servers

While UNIX and Linux computers can be clients to a Samba server, most clients of most Samba servers run Windows®. Therefore, you should know how to use the Windows features that enable you to connect to a Samba server. For example, using certain Samba commands on a Linux computer can help you debug problems should they occur.

Share:

Roderick W. Smith, Consultant and author

Roderick Smith author photoRoderick W. Smith is a consultant and author of over a dozen books on UNIX and Linux, including The Definitive Guide to Samba 3, Linux in a Windows World, and Linux Professional Institute Certification Study Guide. He is also the author of the GPT fdisk partitioning software. He currently resides in Woonsocket, Rhode Island.



29 November 2011

Also available in Chinese Russian Japanese Spanish

About this series

This series of articles helps you learn Linux systems administration tasks. You can also use the material in these articles to prepare for the Linux Professional Institute Certification level 3 (LPIC-3) exams.

See our developerWorks roadmap for LPIC-3 for a description of and link to each article in this series. The roadmap is in progress and reflects the current objectives (March 2011) for the LPIC-3 exams. As each article is completed, it is added to the roadmap.

In this article, learn about these concepts:

  • Features of Windows clients
  • Using browse lists from Windows
  • Creating file and printer shares in Windows
  • Using smbclient for testing
  • Using the Windows net utility

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.

Prerequisites

About the elective LPI-302 exam

Linux Professional Institute Certification (LPIC) is like many other certifications in that different levels are offered, with each level requiring more knowledge and experience than the previous one. The LPI-302 exam is an elective specialty exam in the third level of the LPIC hierarchy and requires an advanced level of Linux systems administration knowledge.

To get your LPIC-3 certification, you must pass the two first-level exams (101 and 102), the two second-level exams (201 and 202), and the LPIC-3 core exam (301). After you have achieved this level, you can take the elective specialty exams, such as LPI-302.

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

Build your own feed

You can build a custom RSS, Atom, or HTML feed so you will be notified as we add new articles or update content. Go to developerWorks RSS feeds. Select Linux for the zone and Articles for the type, and type Linux Professional Institute for the keywords. Then, choose your preferred feed type.

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:

  1. In Control Panel, click System and Security, and then click System.

    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
    Screenshot of the Windows control panel
  2. 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
    Screenshot of the System properties showing the Computer description set to 'Wembleth' and the workgroup set to RINGWORLD
  3. Change the Computer description field to show something informative, as suggested by the prompt below that field.
  4. 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
    Screenshot showing how one would edit the Computer name, Workgroup, or join a Domain
  5. Type the computer's NetBIOS name in the Computer name field.

    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.

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

  7. Select the Domain or Workgroup option, as appropriate, and type your local domain or workgroup name in the associated field.

    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.

  8. 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:

  1. 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
    Screenshot showing Windows explorer with a view of the storage devices and their used capacity

    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.

  2. 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:

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

  2. 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.
Screenshot shows mapping the z drive in Windows to the share on \\WEMBLETH\Users and to reconnect at logon

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.

To create a printer queue in Windows, complete these steps:

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

  2. 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
    Screenshot shows Windows with a list of printer shares
  3. 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.

  4. 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.
  5. 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
Screenshot shows selecting the \\NESSUS\hp4000 printer from the print dialog box

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 single command.

To use net, you type the command followed by a subcommand name, some of which require additional options. Table 1 summarizes the most important net subcommands.

Table 1. Subcommands of the Windows net command
SubcommandEffect
CONFIGDisplays or updates various network settings, such as the computer's NetBIOS name and workgroup or domain name
FILEWhen typed on a Windows file server, displays information on shared files opened by clients
HELPDisplays help information for the use of the net command
SESSIONWhen typed on a Windows file server, displays active connections from clients; adding /DELETE terminates a session
STATISTICSDisplays statistics on sent and received bytes, errors, and so on associated with client (NET STATISTICS WORKSTATION) or server (NET STATISTICS SERVER) operations
TIMESets the computer's clock to match that of another computer
USEMaps a share to a Windows drive letter or displays information on current mappings
USERAdds, deletes, or modifies a user account stored on a domain controller
VIEWDisplays 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 VIEW followed by 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.

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

  1. Browse to the drive or directory you want to share.
  2. Right-click the drive or directory, and then point to Share with, which has a submenu with various options.
  3. 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
    Screenshot shows File Sharing dialog where the Homegroup is being given read permissions and rodsmith is set as owner
  4. Select a user or group from the Add list, or type a user name in the box.
  5. Click Add.
  6. 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:

  1. Install and configure a printer queue for the local printer.
  2. In the Control Panel's Hardware and Sound item, click Devices and Printers.
  3. Right-click the printer you want to share, and then click Printer Properties.
  4. 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
    Screenshot shows how one accesses the Network and Sharing Center through a printer's properties
  5. 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.

  6. 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 SMB/CIFS, Objective 314.4 also mentions rdesktop, so 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 mount command and cifs file system tools, as described in the article "Learn Linux, 302 (Mixed environments): CIFS integration." (In the past, the smbmount and 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.)

Typing mount //SERVER/SHARE /mnt, where 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 dmesg). It 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 settings.

Testing using smbclient

The smbclient program, which is described in the article "Learn 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

The 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 this URI:

$ 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 smbget's 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 operation.

Testing using rdesktop

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

To use 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.

Resources

Learn

Discuss

  • Get involved in the My developerWorks community. Connect with other developerWorks users while exploring the developer-driven blogs, forums, groups, and wikis.

Comments

developerWorks: Sign in

Required fields are indicated with an asterisk (*).


Need an IBM ID?
Forgot your IBM ID?


Forgot your password?
Change your password

By clicking Submit, you agree to the developerWorks terms of use.

 


The first time you sign into developerWorks, a profile is created for you. Information in your profile (your name, country/region, and company name) is displayed to the public and will accompany any content you post, unless you opt to hide your company name. You may update your IBM account at any time.

All information submitted is secure.

Choose your display name



The first time you sign in to developerWorks, a profile is created for you, so you need to choose a display name. Your display name accompanies the content you post on developerWorks.

Please choose a display name between 3-31 characters. Your display name must be unique in the developerWorks community and should not be your email address for privacy reasons.

Required fields are indicated with an asterisk (*).

(Must be between 3 – 31 characters.)

By clicking Submit, you agree to the developerWorks terms of use.

 


All information submitted is secure.

Dig deeper into Linux on developerWorks


static.content.url=http://www.ibm.com/developerworks/js/artrating/
SITE_ID=1
Zone=Linux
ArticleID=777181
ArticleTitle=Learn Linux, 302 (Mixed environments): Working with Windows clients
publish-date=11292011