Web Niraj
  • Facebook
  • Flickr
  • Github
  • Instagram
  • Linkedin
  • Twitter
  • YouTube
Online portfolio, code examples and developer blog
  • About
  • Contact
  • Portfolio
  • WordPress
  • Apps
    • Gemini Quota App for macOS
Search the site...
  • Home
  • Blog
  • Securely Delete a cPanel User’s Files and Account

Securely Delete a cPanel User’s Files and Account

0

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:

#!/bin/bash
# Check if username is provided
if [ -z "$1" ]; then
echo "Usage: $0 <username>"
exit 1
fi
USERNAME=$1
find "/home/$USERNAME" -type f -exec shred -uvz {} \;
/usr/local/cpanel/scripts/removeacct --force "$USERNAME"
view raw secure-remove.sh hosted with ❤ by GitHub

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.

Command Line, cPanel / WHM, Security

Leave a Reply Cancel reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.

StackExchange / StackOverflow

profile for Niraj Shah on Stack Exchange, a network of free, community-driven Q&A sites

Subscribe for updates

Support Me

Buy Me a Coffee

PSN Profile

Tags

ACL Amazon Web Services Android Android 4.4 KitKat Android 5.0 Lollipop Apache Backup Bug Command Line Cordova cPanel / WHM Facebook Facebook Graph API Facebook PHP SDK 4.0 Facebook Social Plugins Fan Page Flash Flat File Geolocation Google Nexus 5 Hacking HTML5 iOS JavaScript jQuery Laravel 5 Linux Mac OS MongoDB NodeJS Parse PDF PHP Plugin Portfolio PS4 Review Security Server SSH SSL Sysadmin Tutorial WordPress WordPress Plugins

© 2011-2026 Niraj Shah
  • Blog
  • Portfolio
  • WordPress
  • About Me
  • Contact Me
  • Privacy Policy