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 |
nmblookup -T WORKGROUP |
Performing backups of Windows computers from the Unix command line
smbclient //cholera/C$ -Tc backup.tar |
smbclient //cholera/C$ -Tc backup.tar "Documents and \ Settings/tjnelson.CHOLERA.003/Desktop" |
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 |
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:
- Start | My Computer
- Right-click on "Drive C"
- Choose Sharing and Security
- It will say "If you understand the risk but still want to share the root of the drive, click here"
- Click there.
- Click on "Sharing and Security" -> Security and set the permissions as appropriate.
- Open Windows Explorer by clicking Start | Run and type "explorer".
- Tools | Folder Options | View
- Uncheck "Use Fimple File Sharing"
- Try disabling the firewall and any other security software.
- If this doesn't work, some people suggested disabling smb signing
by editing the following key with regedit.
HKEY_LOCAL_MACHINE\system\currentcontrolset\services\lanmanserver\parameters\
This key is in requiresecuritysignature. I did not try this. - If it still doesn't work, download and compile a new version of samba from www.samba.org
- 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 |
A message box like this will pop up on their computer:
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 &' |
Back