How to Stop Ubuntu Linux from Automatically Creating Hidden Files

The “.Trash” and “.directory” Clutter

If you use Ubuntu Linux alongside other operating systems (like dual-booting with Windows) or if you frequently share external USB drives, you may notice an annoying phenomenon. Ubuntu has a habit of silently creating hidden folders and files—such as .Trash-1000, .directory, or .fseventsd—on every partition and flash drive you mount. On Linux, any file starting with a dot (.) is hidden, so you rarely notice them. However, when you plug that same USB drive into a Windows machine or a smart TV, those files are fully visible, cluttering up your root directories and creating confusing “Trash” folders that you never explicitly made.

Understanding the Hidden Files

These files are not viruses; they are functional components of the Linux filesystem and the GNOME desktop environment:

  • .Trash-1000: This is a local recycle bin. When you delete a file on a USB drive in Ubuntu, it isn’t permanently erased; it is moved to this hidden folder so it can be restored if needed.
  • .directory: Often created by file managers (like KDE’s Dolphin) to store folder view preferences (icon sizes, sorting order).

How to Prevent Automatic Trash Folders

The most common annoyance is the .Trash folder. If you want files to be permanently deleted immediately from external drives without creating a hidden backup folder, you can configure the GNOME file manager (Nautilus) to bypass the trash entirely.

1. Open your Files application (Nautilus).

2. Click the hamburger menu (three horizontal lines) in the top-right corner of the window.

3. Select Preferences.

4. In the Preferences window, look for the Action to open items or Behavior section.

5. Check the box next to Show action to permanently delete files and folders.

Now, when managing files on a USB drive, instead of pressing Delete (which moves them to the hidden .Trash-1000 folder), you can select the file and press Shift + Delete. This permanently destroys the file immediately, preventing Ubuntu from automatically generating the hidden trash directory on your external media.

Cleaning Up Existing Clutter

Unfortunately, you cannot completely prevent Ubuntu from writing indexing or metadata files to external drives at the kernel level without mounting the drive as “Read-Only.”

If you need to quickly sanitize a USB drive before handing it to a Windows user, open your terminal, navigate to the USB drive’s mount point (e.g., cd /media/username/USB_DRIVE), and run the following command to instantly wipe all hidden files and folders in the root directory:

rm -rf .*

Warning: Use this command with extreme caution, as it will delete all hidden configurations in whichever directory you run it.

Get the best tech tips delivered straight to your inbox.

Join thousands of readers mastering Apple, Google, Microsoft, and Linux.