Following on from my previous article on How to Securely Delete Files on Linux, I recently had the need to apply this to cPanel. After moving user accounts to a new server, I wanted to securely delete all the files and accounts from the old server.
To achieve this, I combined the command line covered in my previous article along with a cPanel specific script, namely, the removeacct script that can be used to remove a user’s account from the command line. Note that root login credentials are required to run this script.
While the removeacct deletes the user’s files and account, it does not delete them securely. So, I used the following script to combine the secure shred method and removeacct:
The secure-remove.sh script above accepts a cPanel account name as the first parameter, e.g.:
./secure-remove.sh accountname
If an improper name or path is provided, both scripts (on lines 11 and 12) will terminate cleanly. Keep in mind that the removeacct script employs the --force flag, meaning the user’s cPanel account is removed even if all files are not securely wiped.

