20 Examples: Make Sure Unix / Linux Configuration Files Are Free From Syntax Errors

Posted on in Categories Howto, Linux, Sys admin, Tips, UNIX last updated February 27, 2016

In Linux and UNIX system services are configured using various text files located in /etc/ or /usr/local/etc/ directory tree. A typical server system could have dozens of configuration files.You can check your configuration files for syntax errors without starting the server and validate all settings. In some cases, it is possible to to check the sanity of the specific data (such as keys) or directories (such as /var/lib/cache/). Text files are easier to manage remotely. You can use ssh and a text editor. If there is an error in configuration, the server may not start. It may result in a disaster. This post explains how to quickly how to find out a syntax error for popular servers and test configuration file for syntax errors.

Lighttpd Control a Directory Listing With mod_dirlisting

Posted on in Categories Howto, lighttpd, Linux, Security, UNIX last updated March 8, 2008

Lighttpd web server will generate a directory listing if a directory is requested and no index-file was found in that directory. mod_dirlisting is one of the modules that is loaded by default and doesn’t have to be specified on server.modules to work.

Task: Enable Directory Listings Globally

Open lighttpd configuration file:
# vi /etc/lighttpd/lighttpd.conf
Append / modify
server.dir-listing = "enable"
dir-listing.activate = "enable"
Save and close the file. Restart lighttpd:
# /etc/init.d/lighttpd restart
To disable directory listing, use:
dir-listing.activate = "disable"

Enable directory listing only for a directory

You can also enable or disable listing on selected url / directory combination. For example, display directory listing only for /files/:
$HTTP["url"] =~ "^/files($|/)" { server.dir-listing = "enable" }
$HTTP["url"] =~ "^/files($|/)" { dir-listing.activate = "enable" }

Further readings:

Check BIND – DNS Server configuration file for errors with named-checkconf tools

Posted on in Categories BIND Dns, CentOS, Debian Linux, Linux, RedHat/Fedora Linux, Sys admin, Tips, Troubleshooting, UNIX last updated October 12, 2007

You can use a tool called named- checkconf to check BIND dns server (named daemon) configuration file syntax under Linux / UNIX. It checks the syntax, but not the semantics, of a named configuration file i.e. it can check for syntax errors or typographical errors but cannot check for wrong MX / A address assigned by you. Nevertheless, this is an excllent tool for troubleshooting DNS server related problems.

How do I check my bind configuration for errors?

Simply run command as follows:
# named-checkconf /etc/named.conf
You may want to chroot to directory so that include directives in the configuration file are processed as if run by a similarly chrooted named:
# named-checkconf -t /var/named/chroot /etc/named.conf
If there is no output, the configuration is considered correct and you can safely restart or reload bind configuration file. If there is an error it will be displayed on screen:
# named-checkconf /etc/named.conf

/etc/named.conf:58: open: /etc/named.root.hints: file not found

Related tool: BIND-DNS server zone file validity checking tool

Gnome per user language encoding configuration using .dmrc file

Posted on in Categories Gnome, Howto, Linux, Linux desktop last updated September 8, 2007

Sometime you may see different language encoding in X than on your console (tty) prompt. Sometime two different user need two have different language encodings.

~/.dmrc file – Per-user language support

In theory this file should be shared between GDM (Gnome) and KDM (KDE), so users only have to configure things once. This is a standard .ini kind / style configuration file. It has only one section called [Desktop] which has two keys: Session and Language. There are some per user configuration settings that control how GDM behaves. GDM is picky about the file ownership and permissions of the user files it will access, and will ignore files if they are not owned by the user or files that have group/world write permission. Normally GDM will write this file when the user logs in for the first time, and rewrite it if the user chooses to change their default values on a subsequent login.

Setup language encoding in X

Defining LANG variable is not sufficient, you need to setup language encoding using ~/.dmrc file.
cat ~/.dmrc


Refer to Gnome Display Manager Reference Manual for more information.