How do I find all the files owned by a particular user or group?

by nixcraft on March 28, 2006 · 2 comments

Q. How do I list or find all the files owned by a particular system user or group under Linux or UNIX operating system?

A. Only find command (search for files in a directory hierarchy) got options that allow you to search files owned by a specific user or groups.

Find file owned by group

Use following syntax:
find directory-location -group {group-name} -name {file-name}
Where,

  • directory-location : Try to find files in this directory path
  • -group { group-name} : Find file belongs to group-name.
  • -name {file-name} : Actual name of file to search

For example, locate or find all file belongs to group "ftpusers" in /home directory, enter:
# find /home -group ftpusers
Find all *.c file belongs to group "ftpusers" in /data/project directory:
# find /data/project -group ftpusers -iname "*.c"

Find file owned by user

Use following syntax:
find directory-location -user {username} -name {file-name}
Where,

  • directory-location : Try to find files in this directory path
  • -user { group-name } : Find file belongs to username.
  • -name {file-name} : Actual name of file to search

For example, locate or find all file belongs to user vivek in /var directory:
# find /var -user vivek
Find all *.pl files file belongs to user vivek in /var/www directory
# find /var/www -user vivek -name "*.pl"

See also:

Featured Articles:

Share this with other sys admins!
Facebook it - Tweet it - Print it -

{ 2 comments… read them below or add one }

1 Marcelo April 8, 2010

Thank you. This article taught something very important today.

Reply

2 Anon June 28, 2011

Thanks, works well!

Reply

Leave a Comment

You can use these HTML tags and attributes for your code and commands: <strong> <em> <ol> <li> <u> <ul> <blockquote> <pre> <a href="" title="">
What is 6 + 9 ?
Please leave these two fields as-is:
Solve the simple math so we know that you are a human and not a bot.




Previous post:

Next post: