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

~4 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