How to Find Files Belonging to a Specific Group in Ubuntu (find -group)

The Ownership Audit

In Ubuntu Linux, every file and directory is assigned both a user owner and a group owner. When managing shared directories (like a /var/www/ web root accessed by multiple developers), ensuring that all files possess the correct group ownership is critical for collaborative security. If a file is accidentally created with the wrong group assignment, other members of the team will be locked out. To quickly audit a massive directory structure and locate files owned by a specific group, you must leverage the native Linux search utility.

Using the find Command with -group

The Linux find command utilizes the -group flag to explicitly search the filesystem based on group ownership metadata.

  1. Open your Terminal application (Ctrl + Alt + T) or log into your server via SSH.
  2. To search the /var/www/ directory and return an exact list of all files owned by the www-data group, type the following command exactly:
  3. sudo find /var/www/ -group www-data
  4. Press Enter and provide your administrator password.

Targeted Collaboration Security

The -group flag instructs the search engine to completely ignore the user owner, the filename, and the creation date. It focuses entirely on the GID (Group ID) metadata attached to the file’s inode. This command is highly flexible; you can combine it with the negation operator (! -group www-data) to instantly isolate every single rogue file in a shared directory that is not owned by the correct administrative group, allowing you to rapidly fix permissions and secure the collaborative environment.

Get the best tech tips delivered straight to your inbox.

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