How to Find Files and Print Their Group Name in Ubuntu (find -printf)

The Ownership Identification Challenge

When auditing shared directories on a multi-user Ubuntu Linux server, simply listing files using ls -l is sufficient for manual inspection, but highly inefficient for automated reporting. If you need to generate a strictly formatted CSV file mapping thousands of document paths directly to the specific security group that owns them (e.g., finance_group or dev_team), extracting this exact string using awk is unnecessarily complicated. You need the search engine to natively output the exact group name alongside the file path.

Using the find Command with -printf

The Linux find command utilizes the highly adaptable -printf flag to explicitly format the search results, allowing you to extract the raw group name string directly.

  1. Open your Terminal application (Ctrl + Alt + T) or log into your server via SSH.
  2. To scan the /shared/projects/ directory and print a clean list showing the group name followed by the exact file path, type the following command exactly:
  3. find /shared/projects/ -type f -printf "%g - %p\n"
  4. Press Enter.

String Formatting Directives

The -printf string utilizes precise extraction directives. The %g directive explicitly pulls the human-readable group name (not the numerical GID) assigned to the file. The hyphen and spaces are literal text used for visual separation. The %p directive extracts the full, absolute file path. Finally, the \n acts as a carriage return, printing each result on a strict new line. This command is an absolute necessity for system administrators building automated ownership audit reports for compliance purposes.

Get the best tech tips delivered straight to your inbox.

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