Complete Guide to Customizing Users in DirectAdmin: Command Control, Domain Limits, Default Pages, Embedded Scripts, and Password Restrictions

This article provides a comprehensive overview of how to customize user behavior and capabilities in DirectAdmin. It covers the use of all_pre.sh for command-level control, preventing subdomain creation, limiting the number of domains on a server, customizing default index pages, running embedded scripts, editing templates safely, creating custom subdomain index pages, and restricting password changes.

DirectAdmin user customizationall_pre.sh, domain_create_pre.sh, default index.html, subdomain scriptspassword restrictions

~3 min read · Updated Mar 1, 2026

1. Using all_pre.sh to Control User Commands


The all_pre.sh script is one of the most powerful customization tools in DirectAdmin. It runs before every /CMD_* request.


Path:

/usr/local/directadmin/scripts/custom/all_pre.sh

If the script returns 0, the command is allowed. If it returns non zero, the command is blocked and the script’s output is shown to the user.


Example: Preventing Email Accounts with Quota > 50MB

#!/bin/sh

if [ "$command" = "/CMD_EMAIL_POP" ] && [ "$domain" = "thedomainyouwant.com" ]; then
    if [ "$action" = "create" ] || [ "$action" = "modify" ]; then
        if [ "$quota" -eq 0 ]; then
            echo "you cant have unlimited quota";
            exit 1;
        fi
        if [ "$quota" -gt 50 ]; then
            echo "you cant have more than a 50 meg quota";
            exit 2;
        fi
    fi
fi
exit 0;

Make it executable:

chmod 755 /usr/local/directadmin/scripts/custom/all_pre.sh

This method can be used to restrict virtually any DirectAdmin command.


---

2. Preventing Users from Creating Subdomains of Your Domain


If you want to prevent users from creating subdomains under your main domain, use domain_create_pre.sh.


Create:

/usr/local/directadmin/scripts/custom/domain_create_pre.sh

Content:

#!/usr/local/bin/php

Make executable:

chmod 755 /usr/local/directadmin/scripts/custom/domain_create_pre.sh

This script runs as root, so you can perform deeper validation if needed.


---

3. Limiting the Number of Domains on the Server


To cap the total number of domains on the server, use domain_create_pre.sh.

Create:

/usr/local/directadmin/scripts/custom/domain_create_pre.sh

Content:

#!/bin/sh
MAX_DOMAINS=10

CURRENT=`ls -la /etc/virtual/ | grep drwx | grep -v majordomo | grep -v usage | grep -c drwx`

if [ "$CURRENT" -ge "$MAX_DOMAINS" ]; then
       echo "Maximum number of domains ($MAX_DOMAINS) has already been created. Cannot create any more."
       exit 1;
fi
exit 0;

Make executable:

chmod 755 /usr/local/directadmin/scripts/custom/domain_create_pre.sh

To prevent creating users when domain limits are reached:

cd /usr/local/directadmin/scripts/custom
ln -s domain_create_pre.sh user_create_pre.sh

---

4. Customizing the Default index.html for New Domains


When a new domain or user is created, DirectAdmin copies the default index.html from:

/home/RESELLERNAME/domains/default/index.html

Available tokens:

  • |DOMAIN|
  • |USERNAME|
  • |DATECREATED|
  • |IP|

All files must be world-readable (755) because they are copied by the new user’s process.


---

5. Running Embedded Scripts Inside index.html


You can embed scripts inside the default index.html template:

|$/usr/local/bin/php

DONE|

The script runs as the user, not as admin.


---

6. Editing Templates, Messages, and Default Files Safely


Templates are located in:

/usr/local/directadmin/data/templates

These files are overwritten during DirectAdmin updates. To customize them safely:

/usr/local/directadmin/data/templates/custom

Files in custom override the originals.


To customize the default directory templates:

/usr/local/directadmin/data/templates/custom/default/*

Note: A reseller’s domains use the creator’s default directory, not their own.


---

7. Creating a Custom index.html for New Subdomains


Since DirectAdmin does not have a built-in template for subdomain index pages, use:

/usr/local/directadmin/scripts/custom/subdomain_create_post.sh

Content:

#!/bin/sh
INDEX=/home/$username/domains/$domain/public_html/$subdomain/index.html
rm -f $INDEX
cp /your/custom/index.html $INDEX
chown $username:$username $INDEX
exit 0;

Make executable:

chmod 755 /usr/local/directadmin/scripts/custom/subdomain_create_post.sh

---

8. Preventing Users from Changing Their Password


If you want to block users from changing their own passwords (while allowing their creator to change it), use:

/usr/local/directadmin/scripts/custom/user_password_change_pre.sh

Content:

#!/bin/sh
if [ "$called_by_self" = "1" ]; then
       echo "You cannot change your own password.";
       exit 1;
fi
exit 0;

Make executable:

chmod 755 /usr/local/directadmin/scripts/custom/user_password_change_pre.sh

Written & researched by Dr. Shahin Siami

Related Articles

Email Client Configuration & Dovecot Quota/Monitoring Guide for DirectAdmin Users

This guide explains how to configure popular email clients (iPhone Mail, Thunderbird, Gmail POP/SMTP), enable Dovecot LMTP quota warnings, and check the last login time for all email accounts on a DirectAdmin server. It includes step by step instructions, recommended IMAP/SMTP settings, and useful administrative scripts.

Continue

Troubleshooting Dovecot in DirectAdmin – Fixing IMAP Errors, Authentication Issues, and SSL Certificate Checks

Dovecot is the IMAP/POP3 server used by DirectAdmin. Sometimes users encounter errors such as “Connection dropped by IMAP server” or “unknown user” during authentication. This guide explains how to fix corrupted Dovecot indexes, understand authentication logs, hide unnecessary warnings, and manually inspect SSL certificates on IMAP ports 143 and 993.

Continue

DNS Troubleshooting in DirectAdmin – When named is Running but Domains Do Not Resolve

Sometimes the named (BIND) service runs normally, yet DNS queries fail or domains do not resolve from outside. This guide provides a complete troubleshooting workflow for checking named listeners, firewall rules, named.conf configuration, DNS propagation issues, subdomain problems, resolv.conf errors, and common Apache/Nginx misconfigurations.

Continue

Managing DNS Records in DirectAdmin – Complete Practical Guide for Administrators

DirectAdmin provides a powerful DNS management system that allows administrators to control TTL values, create SRV records, enable DNSSEC, manage subdomain delegation, automate TLSA records, and perform mass DNS updates. This guide explains all essential DNS operations in DirectAdmin with real-world examples and best practices.

Continue

DNS and Nameservers in DirectAdmin – Complete, Practical, and Professional Guide

DNS is the backbone of the internet, responsible for translating domain names into IP addresses. DirectAdmin allows you to create private nameservers (ns1/ns2), manage DNS zones, configure DNS clustering, use external DNS, and troubleshoot common issues. This guide provides a complete, clear, and practical explanation of DNS concepts and their implementation in DirectAdmin.

Continue

CustomBuild in DirectAdmin – Complete Guide to Installation, Updates, Configuration, and Advanced Customization

CustomBuild is DirectAdmin’s primary software management system. It installs, updates, configures, and rebuilds essential services such as Apache, Nginx, PHP, MariaDB/MySQL, Exim, Dovecot, FTP servers, and more. Because most components are compiled from source, CustomBuild offers exceptional flexibility, fast access to new versions, and optimized performance.

Continue