How to Empty / Delete files .trash folder cPanel users

How to Empty or Delete the .trash Folder for cPanel Users

The .trash folder located at /home/$username/.trash contains any files that a user has deleted via their cPanel File Manager. Over time, this folder can consume significant disk space. Here is how to clean it up efficiently.

Why Does the .trash Folder Fill Up?

When cPanel users delete files through the File Manager, the files are moved to the .trash directory instead of being permanently deleted. This acts as a recycle bin, but many users forget to empty it, leading to disk quota issues.

Method 1: Empty Trash via cPanel File Manager

  1. Log in to cPanel.
  2. Open the File Manager.
  3. Click the "Empty Trash" button in the toolbar at the top.
  4. Confirm the deletion when prompted.

Method 2: Delete .trash via SSH (Single User)

Connect to your server via SSH and run:

rm -rf /home/username/.trash/*

Replace username with the actual cPanel username.

Method 3: Delete .trash for ALL cPanel Users via SSH

If you are the server administrator and want to clear trash for every account:

for user in $(ls /var/cpanel/users); do rm -rf /home/$user/.trash/*; echo "Cleared trash for $user"; done

Automating Trash Cleanup with a Cron Job

To automatically clean all trash folders daily, add a cron job as root:

0 3 * * * for user in $(ls /var/cpanel/users); do rm -rf /home/$user/.trash/*; done

This runs every day at 3:00 AM and removes all trashed files.

Checking Trash Folder Size

Before deleting, you can check how much space the trash is consuming:

du -sh /home/*/. trash/

Important Notes

  • Files deleted from .trash are permanently removed and cannot be recovered.
  • Always verify you have backups before bulk-deleting trash across all accounts.
  • Consider setting up disk quota warnings so users are alerted before running out of space.
  • cpanel, trash, disk-space, file-manager
  • 1 Benutzer fanden dies hilfreich
War diese Antwort hilfreich?