testparm
Validate Samba configuration file
SYNOPSIS
testparm [options] [configfile] [hostname] [hostIP]
PARAMETERS
-s, --suppress-prompt
Suppresses the interactive prompt. This is useful for scripting where no user interaction is desired. The command will exit with a status code indicating success or failure.
-v, --show-defaults
Enables verbose output, showing all parameters including the default values that Samba applies if not explicitly set in smb.conf. Provides a complete view of the effective configuration.
-u
Checks the validity of users mentioned in the configuration. This option may require root privileges to access user account information.
-t, --syntax-only
Performs a syntax check only, without printing the parsed configuration. It returns 0 on success and a non-zero value on error, making it suitable for automated checks.
-l
Logs messages to standard output (stdout) instead of the default syslog or debug file.
-n
Disables the processing of parameter includes. This means any 'include' directives in smb.conf will be ignored.
-h, --help
Displays a brief help message with common command-line options.
-V, --version
Prints the version information for the testparm utility and the Samba suite.
configfile
Specifies an alternative Samba configuration file to check instead of the default (typically /etc/samba/smb.conf).
hostname
Simulates a connection from a specific hostname. This can be used to test host-based access controls defined in the configuration.
hostIP
Simulates a connection from a specific IP address, useful for testing IP-based access restrictions.
DESCRIPTION
testparm is a command-line utility from the Samba suite. Its primary function is to parse and validate the syntax of the Samba configuration file, typically smb.conf. It helps administrators identify and correct syntax errors, preventing potential issues before starting or restarting the Samba daemons. Beyond syntax checking, testparm also displays the effective configuration parameters, including all default values that Samba applies internally. This comprehensive output allows administrators to verify how their settings are interpreted, resolve conflicts, and ensure that global and share-specific options are configured as intended. It can also simulate connections from specific hosts or IP addresses to test access permissions, making it an indispensable tool for pre-deployment validation and troubleshooting.
CAVEATS
testparm primarily checks the syntax and parameter interpretation of smb.conf. It does not perform live network tests, verify actual file system permissions, or diagnose runtime issues of the Samba server. For complete validation, the smbd daemon itself must be run and tested. Some specific checks, such as user validity with the -u option, may require elevated (root) privileges.
NON-INTERACTIVE MODE FOR SCRIPTING
The -s or --suppress-prompt option is invaluable for automation. When used in scripts, testparm runs non-interactively and exits with a status code (0 for success, non-zero for errors), allowing for automated configuration checks as part of continuous integration/deployment pipelines or system health monitoring scripts. This facilitates robust and error-free Samba deployments.
UNDERSTANDING EFFECTIVE CONFIGURATION
The -v or --show-defaults option is crucial for a complete understanding of how Samba will operate. It displays not only the parameters explicitly set by the administrator in smb.conf but also all the default values that Samba applies internally. This comprehensive output helps in debugging unexpected behavior by revealing all active parameters, ensuring administrators have a full picture of their server's configuration.
HISTORY
testparm has been a fundamental component of the Samba suite since its early development. As the complexity of Samba configurations grew, especially with features like Active Directory integration, the importance of a robust configuration validation tool increased. testparm has consistently served as the go-to utility for administrators to ensure the correctness and integrity of their smb.conf files, evolving alongside Samba to support new parameters and syntax, thereby preventing common startup failures and aiding in the deployment of complex server environments.