4

Do you know a command to list all files on the server with specific group and user name?

I am looking for something like this:

find -ls -group 'groupname' && find -ls -user 'username'

this has to list the file with that specific group and user name.

3

find can accept multiple test primitives to determine which files (or directories, etc.) are selected for further processing by find. The command:

find / -user username

will list all files owned by user username. Likewise,

find / -group groupname

Will list all entries that are owned by group groupname. If both tests are given on the find command line, the default operation is to "and" them:

find / -user username -group groupname -ls

2

You can use the find command to specify the user and group while putting multiple options in () with the -a switch inside.

find /the/path -type f \( -user username -a -group groupname \) 

type -f is used to specify files. You can remove it if you also want directories and links.

The parentheses have to be escaped with backslashes.

If you want to pass it to ls:

find /the/path \( -user username -a -group groupname \) -exec ls {} \;

Adding -exec -ls {} \; at the end does that.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.