Site icon Web Niraj

Securely Delete a cPanel User’s Files and Account

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 some cPanel specific scripts. Namely, the removeacct script that cPanel providers 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 invalid name or directory is supplied, both scripts (on lines 11 and 12) will fail gracefully. Note that the removeacct script uses the --force flag, which means the user’s cPanel account will be deleted even if all the files are not securely removed.

Exit mobile version