
The testparm command
The testparm command is used to check the Samba configuration file (/etc/samba/smb.conf) for syntax errors and to display the effective settings Samba will use. It is useful after editing the configuration file to ensure there are no mistakes.
Table of Contents
Here is a comprehensive guide to the options available with the testparm command in Linux −
Syntax of testparm Command
The syntax of the testparm command in Linux is as follows −
testparm [options]
In the above command, the [options] argument is used to specify the option to modify the command's output or behavior.
Options of testparm Command
The options for the testparm command are listed below −
Short Option | Long Option | Description |
---|---|---|
-d DEBUGLEVEL | --debuglevel=DEBUGLEVEL | Sets debug level (0-10) |
--configfile=<configuration file> | Specifies the configuration file. | |
--option=<name>=<value> | Sets the configuration option. | |
-s | --suppress-prompt | Suppresses prompt for carriage return before dumping service definitions. |
-v | --verbose | Outputs all default options not explicitly set in smb.conf. |
--parameter-name <name> | Dumps the specified parameter; defaults to the global section if not specified. | |
--show-all-parameters | Shows the parameters, type, and possible values. | |
--section-name <name> | Dumps the specified section. | |
-l | --skip-logic-checks | Skips the global checks. |
-? | --help | Displays a summary of command-line options. |
--usage | Displays detailed usage. | |
-V | --version | Displays the version number. |
Using testparm Command in Linux
This section explores how to use the testparm command in Linux −
Checking the Syntax of the Samba Configuration File
To check the /etc/samba/smb.conf file for syntax errors and display the configuration, use the testparm command without any options −
testparm

Checking the Syntax without a Prompt
To check the configuration file without prompts, use the -s or --suppress-prompt option −
testparm -s

Displaying All Default Options
To display all default options of the Samba configuration file, use the -v or --verbose option with the testparm command −
testparm -v

Displaying All Parameters
To print all the parameters, use the --show-all-parameters option −
testparm --show-all-parameters

Setting Configuration Option
To set the configuration option, use the --option option followed by the name and value.
testparm --option=workgroup=MYGROUP
Dumping a Specific Parameter
To display a specific configuration parameter, use the --parameter-name option −
testparm --parameter-name workgroup

Dumping a Specific Section
To display a specific section from the configuration file, use the --section-name option −
testparm --section-name printers

Printing Usage Help
To display the usage help of the testparm command, use the --help option −
testparm --help
Conclusion
The testparm command is a helpful tool for verifying the Samba configuration file by checking for syntax errors and showing the settings that will be applied. It is commonly used after making changes to ensure everything is correctly configured.
The testparm command supports several options to control its output, such as displaying default values, suppressing prompts, and showing specific parameters or sections.