Testing Configuration files

Testing Configuration files

by -
0 1276

As a techie, It is very difficult always to remember syntax and parameters accurately, I do mistakes, creates troubles. To counter the errors, most services provide us command to check status of config file for errors. I have collected these commands by the help of my students, my experience..  of-course  from internet. Happy to share with you today.

Note:   Most of the command will be executed by user root only !!

Apache Server/WebServer/httpd Server

  • Config file: /etc/httpd/conf/httpd.conf
  • Port:    80,443

Testing Configuration file:

# httpd -t

For virtual host:

# httpd -t -D  abc.com


Here  we create a virtual host for domain abc.com

# vi /etc/httpd/conf/httpd.conf

………….. in the last lines

<VirtualHost *:80>
ServerAdmin [email protected]
DocumentRoot /home/abc.com
ServerName abc.com
/VirtualHost>                      <———–mistake!!  here tag is not closed

Now check configuration file

# httpd -t

httpd: Syntax error on line 993 of /etc/httpd/conf/httpd.conf: /etc/httpd/conf/httpd.conf:993: <VirtualHost> was not closed.


Listed errors here, after fixing the error ( by closing tag )

<VirtualHost *:80>
ServerAdmin [email protected]
DocumentRoot /home/abc.com
ServerName abc.com
</VirtualHost>                              <————————problem fixed here by closing TAG


Now check the config

# httpd -t

Syntax OK

Testing virtual host

[[email protected] ~]# httpd -t -D abc.com

Syntax OK

Nginx Server:  Web Server

  • Port: 80
  • Config file: /etc/nginx/nginx.conf

Checking Nginx server configiration for syntax errors in Linux

#nginx -t
#service nginx configcheck



SAMBA server:

  • Config file:  /etc/samba.smb.conf
  • Port: 137,138,139,445

Test config :

# testparm
# testparm /etc/samba/smb.conf

Testparm command also shows allow connections:

# testparm /etc/samba/smb.conf MYSERVER

Load smb config files from /etc/samba/smb.conf
Processing section “[homes]”
Processing section “[printers]”
Loaded services file OK.
Allow connection from (MYSERVER) to homes
Allow connection from (MYSERVER) to printers



TCP Wrappers:  ( also known as tcpd service )

  • Config file:  /etc/hosts.allow and  /etc/hosts.deny

Checking TCP wrappers configurations for syntax errors

#tcpdchk -v

Postfix Server/Mail Server

  • CONFIG FILE : /etc/mail/main.cf
  • PORT : 25

Checking POSTFIX server configurations for syntax errors in Linux/Unix

#postfix check
#postfix -vv



Squid Server/Proxy Server:

  • Config File :  /etc/squid/squid.conf
  • Port: 3128

Checking SQUID server configurations for syntax errors in Linux

# squid -k check
# squid -k parse

 If any errors in configuring file shows errors like this

# squid -k check

2016/07/24 21:42:44| parseConfigFile: line 12 unrecognized: ‘   run-time problems.  In some cases “none” refers to no default’

FTP service:

  • Config file : /etc/vsftpd/vsftpd.conf
  • Port: 20,21

Checking vsftpd server confiruations for syntax errors in Linux

# vsftpd

< ……………………..No output means , syntax is ok

Here I created some mistake manually to generate some errors

# vsftpd                              <———————–showing errors

500 OOPS: missing value in config file for:  Allow anonymous FTP? (Beware – allowed by default if you comment this out).


DHCP Server:

  • Config file: /etc/dhcpd.conf
  • Port: 546,547

 Checking DHCP Server configuration  for syntax errors in Linux/Unix

        dhcpd -t -cf /path/to/dhcpd.conf

Note: -cf is a single options, its not -c and -f. And -cf stands for config-file

# dhcpd -t -cf /etc/dhcpd.conf                     <—with erros

Internet Systems Consortium DHCP Server V3.0.5-RedHat
Copyright 2004-2006 Internet Systems Consortium.
All rights reserved.
For info, please visit http://www.isc.org/sw/dhcp/
WARNING: Host declarations are global.  They are not limited to the scope you declared them in.

After fixing the errors:

# dhcpd -t -cf /etc/dhcpd.conf                 <—showing no errors

Internet Systems Consortium DHCP Server V3.0.5-RedHat
Copyright 2004-2006 Internet Systems Consortium.
All rights reserved.
For info, please visit http://www.isc.org/sw/dhcp/

[[email protected] ~]#


DNS Server:

  • Config file: /etc/named.conf
  • Port : 53

Checking DNS server configurations for syntax errors in Linux
Check syntax errors in main configuration file.

  #named-checkconf  main-config-file

 I checked in CentOS 5.4 ( after creating some manual errors) 
# named-checkconf /etc/named.caching-nameserver.conf
/etc/named.caching-nameserver.conf:2: unknown option ‘named.caching-nameserver.conf’

After revert I found

# named-checkconf /etc/named.caching-nameserver.conf

#                    <—————————-no output means, no errors, syntax OK

use named- checkzone command as zone file validity checking tool. It is useful for checking zone files before configuring them into a name serve

# named-checkzone  abc.com   /var/named/abc.zone

zone localhost/IN: loaded serial 42

If you see “OK” as result, the zone file is properly configured and you can restart bind name server.

NAGIOS Server:

Config file:   /usr/local/nagios/etc/nagios.cfg

Checking NAGIOS server configuration for syntax errors in Linux

/usr/local/nagios/bin/nagios -v /usr/local/nagios/etc/nagios.cfg   


SSH Service:

  • Port: 22
  • Config file:  /etc/ssh/sshd_config

Checking SSH server configuration  for syntax errors in Linux.

# sshd -t

sshd re-exec requires execution with an absolute path


Thanking you !!

Linux is like black hole. Once in, never out !!

Use Linux, it works…………….!!

keep sharing and comments

Download PDF

CEO, KV IT-Solutions Pvt. Ltd. | [email protected] | 9810028374|
Linux Professional and an Industrial Trainer | 20 + years Experience in IT Industry

” We are born free, No Gate and Windows can snatch our freedom “


0 1672

0 1328

0 1188


Leave a Reply