smbclient

The Samba Team supplies smbclient as a basic part of the Samba suite. At first, it might seem to be a primitive interface to the SMB network, but smbclient is actually a versatile tool. It can be used for browsing shares on servers, testing configurations, debugging, accessing shared printers, backing up shared data, and automating administrative tasks in shell scripts. And unlike smbfs and smbsh, smbclient works on all Unix variants that support Samba.

In this chapter we’ll focus mostly on running smbclient as an interactive shell, using its ftp-like commands to access shared directories on the network. Using smbclient to access printers and perform backups will be covered in Chapter 10.

A complete reference to smbclient is found in Appendix C.

Listing Services

The -L option can be used with smbclient to list the resources on a single computer. Assuming the Samba server is configured to take the role of the master browser, we can obtain a list of the computers in the domain or workgroup like this:

$ smbclient -L toltec
added interface ip=172.16.1.1 bcast=172.16.1.255 nmask=255.255.255.0
Password:
Domain=[METRAN] OS=[Unix] Server=[Samba 2.2.5]

    Sharename      Type      Comment
    ---------      ----      -------
    test           Disk      For testing only, please
    IPC$           IPC       IPC Service (Samba 2.2.5)
    ADMIN$         Disk      IPC Service (Samba 2.2.5)

    Server               Comment
    ---------            -------
    MAYA                 Windows 98
    MIXTEC               Samba 2.2.5
    TOLTEC               Samba 2.2.5
    ZAPOTEC              

    Workgroup            Master
    ---------            -------
    METRAN               TOLTEC

In the column labeled “Server”,

Get Using Samba, Second Edition now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.