Exchanging Files with Windows Hosts Using smbclient


Exchanging Files with Windows Hosts Using smbclient

You can browse and exchange files with Windows hosts from the Linux command line relatively easily, provided you are somewhat familiar with the process of copying files from computer to computer on Windows networks and the use of the ftp command on Linux or Unix networks.

The command used for exchanging files with Windows hosts is called smbclient. Although smbclient isn't hard to use, you at least need to know the name of the Windows host with which you want to exchange files. If you don't know the name of the Windows host with which you want to communicate, ask your network administrator or consult the Network Neighborhood or My Network Places icons on a Windows desktop computer on your network.

Can't Find smbclient on Your System?

If you didn't choose the Workstation installation of Fedora Core 4 in Chapter 2, "Installing Fedora Core 4," you might not have smbclient installed on your system. If this is true in your case, you should install smbclient before proceeding with the rest of this chapter.

Refer to Chapter 31, "Installing Linux Software," for help installing additional Linux software from your CDs. To follow along with remainder of this chapter, you need to install the "Windows File Server" application group. Doing so installs the smbclient command on your Linux system.


Listing the Shares on a Windows Host

A share is a hard drive or storage area on a Windows host that has been made available to other network users. To list the shares on a Windows host using smbclient, call smbclient from the command line with the -L option and the name of the host as an argument. You are prompted for a password. If no password is required to list the shares on a given host, press Enter. A sample result is shown in Listing 24.1.

Listing 24.1. Sample smbclient Output
 1:  [you@workstation20 ~]$ smbclient -L newton 2:  added interface ip=192.168.1.24 bcast=192.168.1.255 nmask=255.255.255.0 3:  Got a positive name query response from 192.168.1.52 ( 192.168.1.52 ) 4:  Password: 5: 6:     Sharename   Type   Comment 7:     ---------   ----   ------- 8:     WinSpace1   Disk   9GB General-purpose 9:     WinSpace2   Disk   9GB General-purpose 10:     MediaDrive1  Disk   30GB Fast video storage 11:     MediaDrive2  Disk   45GB Fast video storage 12:     Optical    Disk   1.3GB Pinnacle Sierra Optical Drive 13:     lp       Printer 14: 15:     Server        Comment 16:     ------        ------- 17:     NEWTON        Primary video workstation 18: 19:     Workgroup      Master 20:     ---------      ------ 21:     WORKGROUP      SUPERSERV 22:  [you@workstation20 ~]$ 

Listing 24.1 shows that the Windows host called NEWTON (line 17) in the workgroup called WORKGROUP (line 21) is sharing a number of hard drives, an optical drive, and a printer (lines 814). When you know the name of the share you want to access, you can connect to that share directly using smbclient.

Connecting to a Windows Share

To connect to a Windows share using smbclient, supply the full name of the share you want to connect to (including host) as an argument to smbclient in the traditional format, enclosed in quotation marks or single quotes. You are prompted for a password. If no password is required to access the share, press Enter:

 [you@workstation20 ~]$ smbclient '\\newton\mediadrive1' added interface ip=192.168.1.24 bcast=192.168.1.255 nmask=255.255.255.0 Got a positive name query response from 192.168.1.52 ( 192.168.1.52 ) Password: smb: \> 

After you connect and enter the correct password, if necessary, you are at the smbclient prompt.

Navigating and Copying Files with smbclient

When you are familiar with ftp, you will find that using smbclient is easy; the commands are largely the same, as is the method of use.

To get a listing of smbclient commands, type help at the smb: \> prompt. As was the case with ftp, you can access a description of each command by typing help command at the prompt.

After you transfer files to and from the Windows host as necessary, you can close the connection simply by typing quit at the smb: \> prompt. After typing the quit command, you are returned to the Linux command line.



    SAMS Teach Yourself Red Hat(r) Fedora(tm) 4 Linux(r) All in One
    Cisco ASA and PIX Firewall Handbook
    ISBN: N/A
    EAN: 2147483647
    Year: 2006
    Pages: 311
    Authors: David Hucaby

    flylib.com © 2008-2017.
    If you may any questions please contact us: flylib@qtcs.net