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

The Group Ownership Audit

In Ubuntu Linux, system security is heavily reliant on user and group ownership. While you can easily search for files owned by a specific user (like root or john), it is equally important to audit files assigned to a specific group. For example, if you manage a web server, you may need to find every single file owned by the www-data group to ensure web applications have the correct read/write permissions. The Linux search engine includes a dedicated flag designed specifically to isolate files based solely on their group ID.

Using the find Command with -group

The Linux find command utilizes the -group flag to filter the file system and return only the files assigned to the exact group name you specify.

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

Ensuring Proper Permissions

The find command will recursively dig through all subdirectories and output the absolute path of every file matching that group. If you are troubleshooting a “403 Forbidden” error on your website, you can reverse this search by adding the -not flag (e.g., find /var/www/ -type f -not -group www-data). This allows you to instantly pinpoint rogue files that accidentally belong to the wrong group, allowing you to rapidly correct your server’s security posture.

Get the best tech tips delivered straight to your inbox.

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