Common Samba Commands

Getting a list of shares
To get a list of the shares on a Windows computer, type
    smbclient -L septicemia 

Getting a list of computer names
To get a list of Netbios names, type
      nmblookup -S WORKGROUP 
The '-S' option performs a node status query to get the NetBIOS names, while nmblookup with no options should return the IP addresses. The most useful command is
      nmblookup -T WORKGROUP 
which prints a list of hostnames and IP addresses of all the Windows computers. This is much easier than going through the dhcpd.leases file.

Performing backups of Windows computers from the Unix command line
     smbclient //cholera/C$ -Tc backup.tar  
    smbclient //cholera/C$ -Tc backup.tar "Documents and \
will create a tar file on the Unix computer containing all the files from their C drive or desktop, respectively. This can be useful for backing up Windows users or restoring files that they have lost on their computer. Restoring is similar, except you use "-Tx" instead of "-Tc".

This is a lot easier than using Windows' backup utility, because there is less clicking involved.

Transferring files with smbclient

To connect to a Windows computer from Unix, type
    smbclient //cholera/C$ -U username -W workgroup 
    smbclient //cholera/C -U Administrator -W workgroup 
for Windows XP. The "username" parameter can be any valid account name that has sufficient privileges, except in XP where it must be Administrator (a user with Administrator privileges is not sufficient).

Assuming the PC's netbios name is CHOLERA, this command will give you ftp-like access to the C:\ drive.

However, this command doesn't work for Windows XP in its default configuration. To connect to XP, change "security = share" to "security = user" in smb.conf and reconfigure the XP machine as follows:

  1. Start | My Computer
  2. Right-click on "Drive C"
  3. Choose Sharing and Security
  4. It will say "If you understand the risk but still want to share the root of the drive, click here"
  5. Click there.
  6. Click on "Sharing and Security" -> Security and set the permissions as appropriate.
  7. Open Windows Explorer by clicking Start | Run and type "explorer".
  8. Tools | Folder Options | View
  9. Uncheck "Use Fimple File Sharing"
  10. Try disabling the firewall and any other security software.
  11. If this doesn't work, some people suggested disabling smb signing by editing the following key with regedit.
    This key is in requiresecuritysignature. I did not try this.
  12. If it still doesn't work, download and compile a new version of samba from
  13. Try it now.

Click here for an example subnet 1 WINS server conf file.
Click here for an example subnet 1 'other' conf file.
Click here for an example subnet 2 local master conf file.
Click here for an example subnet 2 'other' conf file.
See the file BROWSING.txt (shamelessly stolen from the samba site) for more details.

Sending Windows Instant Messaging Pop-Ups from Linux

Now you too can send annoying popup messages to Windows users! The Windows machine must have IM turned on for this to work.
   smbclient -I ip-address  -M  netbios-name-of-recipient   

The -I option specifies the ip address of the relevant SMB server. The -M option species the name of the Windows computer to connect to. Type the message and then hit Ctrl-D. The '-I' argument is optional if smbclient can find a WINS server. This command is equivalent to the
   net send   
command in Windows.

A message box like this will pop up on their computer:
smbclient message

Receiving Windows Winpopups in Linux

Add the following to the /etc/smb.conf file (on a single line) and restart samba:
   message command = /bin/sh -c 'export DISPLAY=:0.0;\
   /usr/X11R6/bin/xmessage -file %s &' 
This command creates a temporary file in /tmp, owned by the user specified by the "guest account" line in smb.conf. If there is an error or a permissions problem, the command will be ignored. If a window doesn't pop up, debug the command by using 'logger' instead of 'xmessage'. If you forget the "export DISPLAY" part, it will track down the sending computer and deliver the message to the sender's screen instead of the recipient. Not very useful. There is another program called "linpopup" that does the same thing.