How to Find Files Matching Specific User and Group Ownership in Ubuntu (find -user -group)

The Compound Ownership Audit

In Ubuntu Linux, managing complex web application directories (like a shared WordPress /wp-content/uploads/ folder) often results in fragmented file ownership. While you can search for files owned by a specific user (-user) or a specific group (-group) individually, this is insufficient for strict security auditing. If you need to verify that every single file uploaded by the www-data user is also strictly assigned to the www-data group (and not accidentally left in the root group), you must execute a compound search that evaluates both ownership vectors simultaneously.

Using the find Command with -user and -group

The Linux find command allows you to chain the -user and -group flags together to enforce a strict dual-condition ownership filter.

  1. Open your Terminal application (Ctrl + Alt + T) or log into your server via SSH.
  2. To scan the /var/www/ directory and return only the files that are owned by the www-data user AND the www-data group, type the following command exactly:
  3. find /var/www/ -type f -user www-data -group www-data
  4. Press Enter.

Strict Logical AND Evaluation

By default, when you chain multiple criteria together in a find command, the search engine utilizes an implicit logical AND operator. This means the file must pass both tests to be returned in the final output. If a file is owned by the user www-data but belongs to the group admin, the command will instantly discard it. This compound syntax is an absolute necessity for system administrators executing recursive chown scripts who need to verify their exact starting parameters before modifying thousands of file associations.

Get the best tech tips delivered straight to your inbox.

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