Test your Samba server for configuration errors

You can easily test your Samba server for configuration errors. It check an smb.conf configuration file for internal correctness.


If this program reports no problems, you can use the configuration file with confidence that smbd will successfully load the configuration file.

Open a shell prompt. And type the following command:
# testparmOR# testparm /etc/samba/smb.conf

The program will issue a message saying whether the configuration file loaded OK or not. This message may be preceded by errors and warnings if the file did not load. If the file was loaded OK, the program then dumps all known service details to screen.

If testparm finds an error in the smb.conf file it returns an exit code of 1 to the calling program, else it returns an exit code of 0. This allows shell scripts to test the output from testparm.

For example:
if [ $? -eq 0 ]; then
echo "Syntax OK"
echo "Syntax Error"

🐧 If you liked this page, please support my work on Patreon or with a donation.
🐧 Get the latest tutorials on SysAdmin, Linux/Unix, Open Source & DevOps topics via:
CategoryList of Unix and Linux commands
File Managementcat
FirewallAlpine Awall CentOS 8 OpenSUSE RHEL 8 Ubuntu 16.04 Ubuntu 18.04 Ubuntu 20.04
Network Utilitiesdig host ip nmap
OpenVPNCentOS 7 CentOS 8 Debian 10 Debian 8/9 Ubuntu 18.04 Ubuntu 20.04
Package Managerapk apt
Processes Managementbg chroot cron disown fg jobs killall kill pidof pstree pwdx time
Searchinggrep whereis which
User Informationgroups id lastcomm last lid/libuser-lid logname members users whoami who w
WireGuard VPNAlpine CentOS 8 Debian 10 Firewall Ubuntu 20.04

5 comments… add one
  • ken Jul 5, 2007 @ 5:38

    That’s extremely OK!

  • oes tsetnoc Sep 28, 2009 @ 2:15

    well when i tried to configure smba – everything went fine … but when clicked on the icon of UNIX SERVER from WIN xp – got an error stating that I do not have access permission and shld contact administartor of that server ..

  • stainless Dec 24, 2011 @ 20:23

    Doesn’t testparm have to be function? to wrk like that?

    function testparm()
    if [ $? -eq 0 ]; then
    echo “Syntax OK”
    echo “Syntax Error”

    • Lucas Oct 22, 2012 @ 9:32

      No. The $? variable stores the value returned by last program executed, in this case, testparm.

      Try running any program, including one that quit with errors, and then do an echo $? to see the exit code.

  • Matthew Setter Oct 16, 2020 @ 20:23

    You could also use the following to test the configuration:

    testparm -s 2>1 1>/dev/null && echo "ok" || echo "not ok"

Leave a Reply

Your email address will not be published. Required fields are marked *

Use HTML <pre>...</pre>, <code>...</code> and <kbd>...</kbd> for code samples.