Smart Systems for Home

Plain how-to guides for smart home, security and home Wi-Fi

Empty Hidden Linux Trash Folders: A Cleanup Guide

· 6 min read · Home Tech

In this article
  1. What You'll Need
  2. Step-by-Step
  3. Common Mistakes
  4. Tips
  5. Troubleshooting
  6. Frequently Asked Questions

To empty hidden Linux trash folders, you need to delete the contents of the ~/.local/share/Trash directory (and optionally /root/.local/share/Trash if you have root access). This removes files that were deleted via file managers but not yet permanently purged. You'll need a terminal and appropriate permissions.

What You'll Need

  • A terminal window (Ctrl+Alt+T on most distributions)
  • Basic familiarity with command-line navigation
  • Root/sudo access if you want to empty system trash folders (e.g., for other users or the root user)

Step-by-Step

  1. Open a terminal. Press Ctrl+Alt+T or search for "Terminal" in your applications menu.
  2. Check the current trash contents (optional but recommended). Run ls -la ~/.local/share/Trash/files to see what's inside. If the folder doesn't exist, you have no hidden trash to empty.
  3. Empty the trash for your user. Run the following command to delete all files in the trash folder (including subdirectories):
    rm -rf ~/.local/share/Trash/*
    This removes everything inside the Trash folder, including the files and info subdirectories. The system will recreate them as needed when you delete new files.
  4. Verify the trash is empty. Run ls -la ~/.local/share/Trash – you should see an empty directory (or only hidden files like . and ..).
  5. Empty the root user's trash (if you have sudo access). If you've ever used a file manager as root (e.g., via sudo nautilus), run:
    sudo rm -rf /root/.local/share/Trash/*
    This is safe but be careful – only do this if you're sure you don't need those files.
  6. Empty trash for other users (optional). If you have multiple user accounts and want to clean them, you'd need to log into each account or use sudo to delete their trash folders. For example, for a user named john:
    sudo rm -rf /home/john/.local/share/Trash/*
    Replace john with the actual username.
  7. Consider using the GUI file manager instead. Most Linux desktops have a trash icon. Right-click it and select "Empty Trash" – this does the same thing as the commands above, but only for your user.

Common Mistakes

  • Using the wrong path. Some older distributions or custom setups use ~/.Trash or ~/.local/share/Trash – check which one exists first with ls -d ~/.local/share/Trash ~/.Trash.
  • Deleting the Trash folder itself. The command above uses /* to delete contents, not the folder. If you run rm -rf ~/.local/share/Trash (without the /*), you'll delete the folder itself, which can cause file managers to misbehave until it's recreated.
  • Forgetting hidden files. The trash may contain hidden files (starting with a dot). The rm -rf command handles those, but if you use a GUI file manager, make sure you have "Show Hidden Files" enabled (Ctrl+H) to see them.
  • Using sudo unnecessarily. If you only need to empty your own trash, don't use sudo – it can change file ownership and cause permission issues.
  • Assuming the trash is in the same place on all systems. The path ~/.local/share/Trash is standard for most modern Linux distributions (per the FreeDesktop.org spec), but some older systems or unusual setups may differ.

Tips

  • Use the trash-cli tool. If you want a more user-friendly command-line trash manager, install trash-cli (e.g., sudo apt install trash-cli on Debian/Ubuntu). Then you can use trash-empty to empty the trash, which is safer than rm -rf because it checks for mounted drives.
  • Empty trash regularly. Hidden trash folders can accumulate large files, eating disk space. Set a reminder or use a cron job to empty it weekly.
  • Check disk space before and after. Run df -h before and after emptying to see how much space you freed.
  • Be aware of external drives. Files deleted from external drives may go to a trash folder on that drive (e.g., /media/username/drive/.Trash-1000). The command above only clears your home trash. To empty external drive trash, you'd need to navigate to that drive and delete the .Trash-* folder.
  • Use find to locate all trash folders. Run find / -name "Trash" -type d 2>/dev/null to see all trash directories on your system, but be careful – some may be system folders you shouldn't touch.

Troubleshooting

  • "Permission denied" when trying to empty trash. This usually means the trash contains files owned by another user (e.g., from a previous sudo operation). Use sudo rm -rf ~/.local/share/Trash/* to force deletion, but be aware this may leave orphaned entries in the file manager.
  • Files reappear after emptying. This can happen if you have a file manager running that is still writing to the trash. Close all file manager windows and try again.
  • The trash folder doesn't exist. If ls ~/.local/share/Trash returns "No such file or directory", it means you've never deleted anything via a file manager, or your system uses a different location. Check ~/.Trash or /tmp/trash (some lightweight desktops use these).
  • Trash is on a different partition. If your home directory is on a separate partition, the trash might be at ~/.local/share/Trash on that partition. If you're unsure, run mount | grep home to see where your home is mounted.
  • GUI "Empty Trash" doesn't work. Try restarting the file manager (e.g., nautilus -q for GNOME Files) or logging out and back in. If that fails, use the terminal method above.

Frequently Asked Questions

Where is the trash folder in Linux?

For most modern distributions, it's at ~/.local/share/Trash (where ~ is your home directory). Older systems may use ~/.Trash. Files deleted from external drives go to a .Trash-1000 folder on that drive (the number is your user ID).

Is it safe to delete the trash folder contents with rm -rf?

Yes, as long as you use the correct path and include the /* to delete contents only. The system recreates the folder when needed. However, using trash-empty from trash-cli is safer because it handles edge cases like mounted drives.

Why is my trash folder hidden?

Linux uses hidden directories (starting with a dot) to store user configuration and data. The trash folder is hidden to prevent accidental deletion and to keep the home directory clean. You can view it by enabling "Show Hidden Files" in your file manager (Ctrl+H) or using ls -a in the terminal.

Does emptying trash free up disk space immediately?

Yes, the files are permanently deleted, and the space becomes available. However, if the files are on an SSD with TRIM enabled, the space may not be reported as free until the drive's garbage collection runs, but that's automatic.

Can I recover files after emptying the trash?

No, emptying the trash permanently deletes the files. Once they're gone, they can't be recovered through the file manager. If you need to recover a file, you'd have to use specialized data recovery tools, but that's not guaranteed to work, especially on SSDs.

What if I have multiple users on my system?

Each user has their own trash folder in their home directory. You can only empty your own trash without sudo. To empty another user's trash, you'd need to log in as that user or use sudo with the appropriate path, but be careful about permissions.