Useful Samba Networking Commands
There are several useful commands available to the Samba network admin.
When it comes to networking, there are two important points of view... what the server sees and what the client sees. Windows networking relies on extensive (and complex) caching on each client. Sometimes a wait of 5-15 minutes will solve network 'issues' on a client. Other times the server is responsible. You must look in both places to determine the source(s) of your problem(s).
Login as root on the PDC (Primary Domain Controller).
- net status sessions show active sessions
- net status shares show shares
- net rpc info show domain info
- net groupmap list shows samba->win group mappings
- smbstatus -L shows locked files only
- smbstatus get shares and users info, locked files as well
- smbstatus -u <username> shows info relevant to <username> only
- nmblookup <domain>#1b shows the current master browser
- nmblookup <domain>#1d shows the current domain controller
- nmblookup <domain>#1c shows the PDC and BDC on the domain
Type watch <command> to 'watch' the items listed changing every 2 seconds. eg watch 'net status sessions' or watch 'nmblookup TOASTERZDOM#1b'. Quotes optional on most commands, some command lines with options will need them, for example to look in the live log for only 10.0.1.65 netbios activity: type watch 'tail /var/log/samba/nmbd.log | grep 192.168.1.165' won't work without the quotes.
On Windows clients from the dos prompt use nbtstat.
Run it without flags or arguments and you will get a list of commands.
- nbtstat -a RemoteName (adapter status) Lists the remote machines name table given its name
- nbtstat -A IP Address (adapter status) Lists the remote machines name table given its IP address
- nbtstat -c (cache) Lists NBT's cache of remote [machine] names and their IP addresses
- nbtstat - n (names) Lists local NetBIOS names
- nbtstat -r (resolved) Lists names resolved by broadcast and DNS
- nbtstat -R (Reload) Purge & reloads the remote cache name table
- nbtstat -S (Sessions) Lists sessions table with the destination IP address
- nbtstat -s (sessions) Lists sessions table converting destination IP addresses to NetBIOS names
- nbtstat -RR (ReleaseRefresh) Sends Name Release packets to WINS and starts Refresh
Add 'interval' to the end of a command to redisplay selected stats, pausing 'interval' number of seconds between each display. Press CTRL-C to stop. For example to display the cache contents every 5 seconds use nbtstat -c 5.