Open Source

Tech Tip: Debug Samba networks with smbclient

Samba is perhaps one of the most useful products for Linux because it closes the gap between Linux and Windows operating systems, allowing users to share printers and files between Linux, Windows, and Mac OS X clients.

But there may be situations when you need to work on your Linux or Windows servers to test shares, authentication, and so on, and it simply takes too much time to use a GUI program.

Samba includes a command-line tool called smbclient, which is a full-blown Samba client program. Instead of using a GUI program, smbclient can perform everything you would require, and it's faster and provides less ambiguous error messages. Depending on your status, you may have to supply a password to connect.

For example, to see what shares are available on a particular host, use the following:

$ smbclient -L \\HOST

In this case, HOST is the NetBIOS name of the server to connect to.

The output of the smbclient command not only shows a list of file and print shares, but it also displays other information about the server, such as the workgroup name and the name of the server software.

To connect to the network as a particular user, use the -U command-line option and specify the username, as shown below:

$ smbclient -U joe -L \\HOST

You can even set the workgroup name by using the -W command-line option. This is a useful option if you're debugging another network and don't feel like reconfiguring your own machine to use the same workgroup name.

Editor's Picks

Free Newsletters, In your Inbox