Knowledge Base Hub

Browse through our helpful how-to guides to get the fastest solutions to your technical issues.

Home  >  DirectAdmin  >  How to Prevent Users from Deleting Certain Files in DirectAdmin?
Top Scroll

How to Prevent Users from Deleting Certain Files in DirectAdmin?

 2 min

Many clients have no idea about the important files and delete them mistakenly. There is a way to prevent the users from deleting these files with DirectAdmin. For that, you will need admin and SSH access.

By limiting their choices and ability to delete the vital files, we can indirectly emphasize their importance. For example, we will block the users from deleting the /public_html file with the FileManager.

1. Prepare a script as /usr/local/directadmin/scripts/custom/filemanager_pre.sh and enter the given code in it:

#!/bin/sh
if [ "${button}" = "delete" ]; then
if env|grep -m1 -q '=/public_html$'; then
echo "You cannot delete your public_html link!"
exit 1
fi
fi
exit 0

 

2. Save the script and make it ready for execution.

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

 

Try deleting the public_html file now. When you do, it will display the error message: “You cannot delete your public_html link!”

You can use this method to stop users from deleting other files in DirectAdmin.

For our Knowledge Base visitors only
Get 10% OFF on Hosting
Special Offer!
30
MINS
59
SECS
Claim the discount before it’s too late. Use the coupon code:
STORYSAVER
Note: Copy the coupon code and apply it on checkout.