In addition to its core component, Samba comes with a bunch ofpretty powerful ancillary utilities: an SMB client, an SMB filesystemmounter, a backup tool, and a Web-based administration utility. Find outhow you can use them, inside.
You're already familiar with the "smbclient" utility - I used it when first configuring and testing Samba. But "smbclient" can do a lot more than just verify that your Samba installation is working as advertised - it's actually a full-featured FTP-like SMB client that can be used to perform file transfer and manipulation operations with an SMB server.
You can start up "smbclient" by providing it with a host name and share name to access.
Once you're connected to that share, you can use standard commands to transfer files, read file information and perform other common file operations. Consider the following sample session, which should demonstrate most of the common operations:
smb: \> cd
Current directory is \smb: \> mkdir tempsmb: \> cd tempsmb: \temp\> dir . D 0 Tue Oct 8 17:09:182002 .. D 0 Tue Oct 8 17:09:182002 63882 blocks of size 32768. 1681 blocks availablesmb: \temp\> put menu.php putting file menu.php as \temp\menu.php (53.0271 kb/s) (average 53.0273kb/s)smb: \temp\>smb: \> mput *.zipPut file www.zip? ysmb: \> q$
You can obtain help by typing
smb: \> help
ls dir du lcd cdpwd get mget put mputrename more mask del openrm mkdir md rmdir rdprompt recurse translate lowercase printprintmode queue cancel quit qexit newer archive tar blocksizetarmode setmode help ? history!
at the command prompt, or a one-line description of each command by typing "help" followed by the command name.
smb: \> help mkdir
HELP mkdir:<directory> make a directory
In case you're having difficulty connecting to shares, you can have "smbclient" generate debug data by adding the "-d" command-line option, followed by a number from 0 to 10; the higher the number, the greater the level of detail provided. Consider the following example, which demonstrates:
$ /usr/local/samba/bin/smbclient //medusa/music -d 5
Client started (version 2.0.6).resolve_lmhosts: Attempting lmhosts lookup for name medusa<0x20>getlmhostsent: lmhost entry: 127.0.0.1 localhost resolve_hosts: Attempting host lookup for name medusa<0x20>resolve_wins: Attempting wins lookup for name medusa<0x20>bind succeeded on port 0nmb packet from 127.0.0.1(137) header: id=15735 opcode=Query(0)response=No header: flags: bcast=No rec_avail=No rec_des=Yes trunc=No auth=No header: rcode=0 qdcount=1 ancount=0 nscount=0 arcount=0 question: q_name=MEDUSA<20> q_type=32 q_class=1Sending a packet of len 50 to (127.0.0.1) on port 137read_udp_socket: lastip 127.0.0.1 lastport 137 read: 62parse_nmb: packet id = 15735Received a packet of len 62 from (127.0.0.1) port 137nmb packet from 127.0.0.1(137) header: id=15735 opcode=Query(0)response=Yes header: flags: bcast=No rec_avail=Yes rec_des=Yes trunc=No auth=Yes header: rcode=0 qdcount=0 ancount=1 nscount=0 arcount=0 answers: nmb_name=MEDUSA<20> rr_type=32 rr_class=1 ttl=496220 answers 0 char ...... hex 0000C0A8008FGot a positive name query response from 127.0.0.1 ( 192.168.0.143 )Connecting to 192.168.0.143 at port 139write_socket(3,76)write_socket(3,76) wrote 76Sent session requestgot smb length of 0size=0... and so on (snip!) ...
One of the cooler (and also more annoying) things you can do with "smbclient" involves using it to send text messages across a network to Windows workstations. These messages appear on the target Windows workstation via the WinPopup utility. Consider the following example, which demonstrates:
$ /usr/local/samba/bin/smbclient -M medusa
Connected. Type your message, ending it with a Control-Dsystem is going down!sent 25 bytes$
When this message is sent to the Windows workstation named "medusa", it pops up as a dialog box on that machine (note that in order for this to work, WinPopup must be installed on the target system, and must be configured to accept and display messages).