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 significantthe -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 hasyou 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 slashesas 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.