How to Limit Search to a Single Filesystem in Ubuntu Linux (find -xdev)

The Mount Point Problem

On complex Ubuntu Linux servers, the root filesystem (/) is rarely a single physical hard drive. Administrators frequently mount massive external storage arrays, network drives (NFS), or specialized virtual filesystems (like /proc) into standard folders. If you execute a global find command starting at the root directory, the search engine will blindly crawl across these mount points, scanning terabytes of network data and flooding your terminal with “Permission denied” errors as it crashes into virtual system folders. You must explicitly instruct the search engine to respect physical drive boundaries.

Using the find Command with -xdev

The Linux find command utilizes the -xdev (don’t cross devices) flag to restrict the search exclusively to the single physical disk partition where the command was initiated.

  1. Open your Terminal application (Ctrl + Alt + T) or log into your server via SSH.
  2. To search the root directory (/) for large log files, while strictly ignoring all mounted network drives and secondary hard disks, type the following command exactly:
  3. sudo find / -xdev -name "*.log"
  4. Press Enter and provide your administrator password.

Absolute Confinement

The -xdev flag ensures absolute containment. Even if an external 10TB USB drive is actively mounted to /mnt/usb, the find command will reach that specific folder, recognize it as a boundary to a different physical disk, and completely refuse to enter it. This drastically increases the speed of system-level searches and prevents the terminal from hanging indefinitely on slow network connections.

Get the best tech tips delivered straight to your inbox.

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