LinuxCommandLibrary

smbcontrol

Send commands to Samba daemons

SYNOPSIS

smbcontrol {smbd|nmbd|all} {command} [args...]

PARAMETERS

{daemon}
    Specifies which Samba daemon(s) to send the command to. Possible values include smbd (for file and print services), nmbd (for NetBIOS name services), or all (to target all running Samba daemons).

reload-config
    Instructs the daemon(s) to reload their configuration file (smb.conf) without restarting the service, applying new settings dynamically.

shutdown
    Initiates a graceful shutdown of the specified Samba daemon(s).

debug [level]
    Dynamically sets the debug logging level for the daemon. A higher level (e.g., 10) increases verbosity. Omit level to show the current debug level.

ping
    Sends a ping to the daemon to check if it is responsive and running.

status
    Retrieves and displays general status information about the daemon, such as process IDs, open files, and connected clients.

version
    Displays the version information of the Samba daemon.

kill-client <pid>
    Terminates a specific client connection identified by its process ID (PID). This forcefully disconnects the client.

close-share <share_name> <pid>
    Closes all open files on a specific share for a client identified by its PID. Useful for releasing locked resources without disconnecting the client entirely.

tcon-disconnect <tree_id>
    Disconnects a specific tree connect (TCON) by its unique ID. A TCON represents a client's connection to a particular share or IPC$.

force-election
    (nmbd only) Forces the nmbd daemon to initiate a new browse master election process on the network, which can be useful in network browsing troubleshooting.

ip-leases
    (nmbd only) Displays current IP address lease information, relevant when nmbd is operating as a DHCP server or in Active Directory Domain Controller mode.

DESCRIPTION

smbcontrol is a command-line utility used to send control messages to running Samba daemons, primarily smbd and nmbd. It allows administrators to perform various actions, such as shutting down daemons, reloading configuration files, disconnecting clients, or retrieving status information without needing a full service restart. It communicates with the daemons via a control socket. This tool is invaluable for dynamic management and troubleshooting of active Samba services, providing granular control over their operation and making it an essential utility for Samba administrators.

CAVEATS

smbcontrol requires appropriate permissions (typically root or the Samba daemon's user) to send commands. The targeted Samba daemon(s) must be running and accessible via their control sockets (usually in /var/run/samba/) for commands to be successful. Commands affect the running daemon's state and do not modify smb.conf directly.

CONTROL SOCKETS

smbcontrol communicates with running Samba daemons via specialized control sockets, typically located in /var/run/samba/. These sockets facilitate secure inter-process communication, allowing smbcontrol to send commands and receive responses from smbd and nmbd without direct process manipulation.

USAGE EXAMPLES

Reload smb.conf:
smbcontrol smbd reload-config

Kill a client connection (PID 12345):
smbcontrol smbd kill-client 12345

Check nmbd status:
smbcontrol nmbd status

Set smbd debug level to 5:
smbcontrol smbd debug 5

HISTORY

smbcontrol has been an integral component of the Samba suite for many years, evolving alongside the core Samba daemons. Its development has consistently focused on providing administrators with powerful, real-time control over active Samba services. This utility significantly reduces the need for full daemon restarts for routine administrative tasks, enabling dynamic configuration changes and efficient troubleshooting in production environments. It underscores Samba's commitment to robust manageability.

SEE ALSO

smbd(8), nmbd(8), samba(7), testparm(1), net(8), pdbedit(8)

Copied to clipboard