Subscribe to Windows IT Pro
June 05, 2000 02:27 PM

Linux's Smbclient Command

Windows IT Pro
InstantDoc ID #8897
Rating: (4)
The Swiss Army knife of Linux-to-NT tools

In "Connecting Linux Workstations to Windows 2000 and NT Servers," May 2000, I looked at smbmount and smbumount, two commands that typically ship with Linux distributions and let Linux boxes read from and write to file shares on Windows 2000 (Win2K) and Windows NT servers. In this issue, I look at a somewhat broader Linux-to-NT tool, the smbclient utility.

Why another tool? One reason is that Samba, the main Linux-Microsoft file-server interoperability project, doesn't support smbmount and smbumount. Samba, a set of programs that lets you make a Linux box look like a Microsoft file server, comes free with every Linux distribution I've seen. As a result, smbmount and smbumount could fade away. Another reason is that smbclient has more functionality than smbmount and smbumount. In particular, smbclient lets you send messages to Win2K, NT, and Windows workstations; display browse lists; and connect to Server Message Block (SMB) file shares (although in a somewhat less user-friendly manner than smbmount and smbumount do).

Sending Messages to Workstations
You might know the Net Send command, which lets you send realtime, pop-up messages to machines on a Microsoft network. The command

net send jane hi there!

causes a box containing the words "hi there!" to pop up on Jane's machine. You can direct the Net Send command to machine names as well as to usernames, so if Jane's machine is named \\PC004, you could as easily type

net send pc004 hi there!

Smbclient performs this task with the -M option. The command smbclient -M pc004 establishes contact with \\PC004 and waits for you to type your message. When you end the message (by pressing Ctrl+D), smbclient sends it. As with many UNIX and Linux commands, the option's case is significant—the -M option must be uppercase.

Displaying Browse Lists
Sometimes you might want to connect to a share on a server but can't remember the share's name. In that case, you can examine the server's list of shares in My Network Places (in Win2K) or Network Neighborhood (in NT), or you can use Win2K or NT's Net View command: net view \\servername. With smbclient, the -L option returns a list of share names. Of course, a server won't tell just anyone what shares it has—you need to prove that you're a recognized user. That's where smbclient's -U option comes in. Most Samba tools let you pass a user account name and password to Samba. You specify a username simply as -U username, or you can specify both a username and a password with -U username%password. For example, if I wanted to see the shares on an NT server named \\BIGSERVE and I had an account on that system named usermark with a password of swordfish, I could type

smbclient -L //bigserve -U usermark

and the system would prompt me for a password. Alternatively, I could type

smbclient -L //Bigserve -U Usermark%swordfish

If the system that you query is a domain controller, the system will also display the list of servers in the workgroup.

Notice a couple of things in the examples I've used so far. First, you can use uppercase, lowercase, or mixed case on user account and server names. Second, notice that the -L option requires two slashes (//) before the name of the server; in contrast, the -M option doesn't work if you precede the name with slashes—as I finally figured out after 45 minutes of experimentation. I also found that smbclient -L seems not to work on Windows 2000 Professional (Win2K Pro) and Windows 2000 Server (Win2K Server) systems.

Connecting to SMB File Shares
I've said that smbclient lets you access Win2K, NT, and Windows shares from a Linux box, but although that's true, smbclient doesn't let you access them in the way that smbmount does. Instead, you use smbclient to attach to a share and use FTP-like commands to copy files to and from Microsoft network shares.

Related Content:

ARTICLE TOOLS

Comments
  • whoisthat
    4 years ago
    May 08, 2008

    GOOD READING

  • Anonymous User
    7 years ago
    Jun 16, 2005

    hola vengo a flotar

  • Anonymous User
    7 years ago
    Jan 10, 2005

    As I was exploring on this I got this error -
    timeout connecting to 172.16.7.45:139

    I believe file sharing service runs on win 2k and xp professional... do I need to change any setting so that smbclient to look at 445 instead of 139

  • Anonymous User
    7 years ago
    Jan 10, 2005

    Hi -
    I am trying send a text file to a shared printer using the smbclient from last few days but I have not been successful... I tried to execute the above commands to check if I can at least list the shares on my laptop. I am getting following error -

    Unknown parameter encountered: "winbind trusted domains only"
    Ignoring unknown parameter "winbind trusted domains only"
    added interface ip=172.16.4.223 bcast=172.16.4.255 nmask=255.255.255.0
    Connection to Laxk/share failed

    I believ it is something to dow with domain security policy but not sure what needs to be changed and where.

    Would appreciate any ideas to get the resolution.

  • Anonymous User
    7 years ago
    Jan 10, 2005

    Thank you for your service

You must log on before posting a comment.

Are you a new visitor? Register Here

advertisement

advertisement

Windows is a trademark of the Microsoft group of companies. Windows IT Pro is used by Penton Media Inc. under license from owner.