Linux command
testparm 命令
文本
复制后可按需替换文件名、目录或参数。
常用示例
Check the default smb.conf
testparm
Check a specific configuration file
testparm [path/to/smb.conf]
Check and suppress the prompt
testparm -s
Show all parameters
testparm -v
Query a specific parameter
testparm --parameter-name "[server role]"
Query a parameter
testparm --parameter-name "[path]" --section-name "[myshare]"
Check if a specific host
testparm [path/to/smb.conf] [hostname] [host_ip]
说明
testparm is a Samba utility that validates smb.conf configuration files for internal correctness. It parses the configuration, checks for syntax errors and invalid parameter values, and reports any problems found. If the file loads successfully, it displays all known service definitions. When a hostname and IP address are provided as arguments, testparm also checks whether the specified host would be granted or denied access to each configured service, based on the hosts allow and hosts deny directives. The tool returns exit code 0 on success and 1 on error, making it suitable for use in scripts and automated deployment pipelines.
参数
- -s, --suppress-prompt
- Do not prompt for a carriage return after displaying service names.
- -v, --verbose
- Show all options, including defaults not explicitly set in the configuration.
- -l, --skip-logic-checks
- Skip global validation logic checks.
- --parameter-name _NAME_
- Print the value of a specific parameter. Use a colon to specify section context.
- --section-name _NAME_
- Restrict --parameter-name output to a specific configuration section.
- --show-all-parameters
- Show all parameters with their types and possible values.
- -d, --debuglevel _LEVEL_
- Set debug verbosity level (0-10, default 1).
- --debug-stdout
- Send debug output to stdout instead of stderr.
- --configfile _FILE_
- Specify the configuration file location.
- --option _NAME=VALUE_
- Set a specific smb.conf option on the command line.
- -V, --version
- Print version information.
- -?, --help
- Display help.
FAQ
What is the testparm command used for?
testparm is a Samba utility that validates smb.conf configuration files for internal correctness. It parses the configuration, checks for syntax errors and invalid parameter values, and reports any problems found. If the file loads successfully, it displays all known service definitions. When a hostname and IP address are provided as arguments, testparm also checks whether the specified host would be granted or denied access to each configured service, based on the hosts allow and hosts deny directives. The tool returns exit code 0 on success and 1 on error, making it suitable for use in scripts and automated deployment pipelines.
How do I run a basic testparm example?
Run `testparm` in a terminal, then adjust file names, paths, flags, or remote targets for your system.
What does -s, --suppress-prompt do in testparm?
Do not prompt for a carriage return after displaying service names.