Search for files owned by particular owner and group


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Search for files owned by particular owner and group
# 1  
Old 03-09-2018
Search for files owned by particular owner and group

I am searchingfor files owned by particular owner and group in a particular directory including its sub-directories. I use

Code:
find <dir> -user <user> -group <group> -exec ls -l {} \;

It does not work completely. In the sense is a subdirectory is owned by 'user' and group 'group' then all files under that directory are also displayed even though they are owned by different user/group.

Any help?
# 2  
Old 03-09-2018
Code:
find <dir> -user <user> -group <group> -exec ls -ld {} +

# 3  
Old 03-09-2018
I think I did not make it clear. ld will show me only directory/sub-directories. I want all directory, sub-directories and files under the given directory have specified user/group.
# 4  
Old 03-09-2018
if the (sub-) directory satisfies your conditions, your above command will exec ute an ls -l on it, which in turn does not discriminate against them. Does your find version provide the -ls action?
# 5  
Old 03-09-2018
Rudic,

Yes, find version provides ls version. If I give just find command, I get

Code:
/export/home> find . -user root -group other
./sparcs_1
./sparcs_2

Now under two directories sparcs_1 and sparcs_2 there are few files which are owned by root/other and few which are not. But my earlier command lists all the files under sparcs_1 and sparcs_2.
# 6  
Old 03-09-2018
Code:
find . -type f  -user root -group other  -ls

Will return only files meeting the selection criteria. Is that what you need? [-ls] is optional.
# 7  
Old 03-09-2018
No, this does not work because none of the files/sub-directories under current directory is owned by root/other. Some of the files under sub-dirctory are owned by root/other. Consider following

Code:
MY_SERVER:/export/home/sdesai/tools> ls -lrt
total 2
-rwxr-xr-x   1 sdesai   mis           94 Mar  2 08:53 dif
drwxr-xr-x   2 sdesai   mis           96 Mar  9 14:41 sparcs_1
drwxr-xr-x   2 sdesai   mis           96 Mar  9 14:41 sparcs_2
MY_SERVER:/export/home/sdesai/tools> cd sparcs_1
MY_SERVER:/export/home/sdesai/tools/sparcs_1> ls -l
 -rwxrwxrwx  1 oracle  other       1925 Feb 26 04:58 File1.txt
-rwxrwxrwx   1 roor    other       1900 Feb 27 04:58 File2.txt

I want only File2.txt as it is owned by root/other
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

List files whose owner or group is numeric

I want to add a condition is my find command to include files/sub-directory whose owner or group is all numeric number. My current find command is find . \( -user root -o -user soham\) -type f -exec ls -l {} \; 2>&1 ---------- Post updated at 10:20 AM ---------- Previous update was at... (5 Replies)
Discussion started by: Soham
5 Replies

2. AIX

Files without owner and group

Dears it is normal that the below binaries stay without any owner and group I have checked it in many servers and the like the below /usr/lpp/bos.net/inst_root/etc/ipsec# ls -lrt total 248 -r-xr-xr-x 1 987 987 13589 Jun 29 2005 default_group -r-xr-xr-x ... (5 Replies)
Discussion started by: thecobra151
5 Replies

3. Emergency UNIX and Linux Support

To identify the group owner

If I have to identify the group owner of an AIX group, what is the command to be used. Example: there is an mqadm group, how do I find the owner of this group? Please help. (6 Replies)
Discussion started by: ggayathri
6 Replies

4. UNIX for Dummies Questions & Answers

Finding the Group Owner Name

Hi all, How can i find the group owner name...??? Thanks (4 Replies)
Discussion started by: mansahr143
4 Replies

5. UNIX for Dummies Questions & Answers

Group files by owner and show directory

Hello, i would like to find huge files and group them by owners. To find big files i use this command: ls -lR | sort -bnr +4 | head -n 75 which give me 75 biggest files, then i need to see in which subdirectory is every file. second thing i dont know is how to group those files by owner, could... (6 Replies)
Discussion started by: dealer1985
6 Replies

6. Shell Programming and Scripting

search files with owner having execute permission

Hi All, I have to search for all files in the current directory where the owner having execute operation. I can find the files with specific permission such as 666 find . -type f -perm 666 But how to find files with only execute permission to user. tried with : find . -type f... (3 Replies)
Discussion started by: gotam
3 Replies

7. UNIX for Advanced & Expert Users

How UNIX admin set up this? how files of 744 of other owner can be removed by another owner?

Hi all, We have some files are under 744 permissions and the the owner is say owner1 and group1. Now we have another user owner2 of group2, owner2 can remove files of the owner1 and the permission of those files are 744, unix admin told us he did some config at his side so we can do that. ... (14 Replies)
Discussion started by: TheGunMan
14 Replies

8. Cybersecurity

File owned by oracle user and dba group need readonly access to other users

Under oracle user file abc.txt was created. Oracle user belong to dba group on UNIX Server. However other non Oracle users which belongs to some other network groups need read only access to this file. Every time when I login as other then oracle user and try to view this file it saying that I... (2 Replies)
Discussion started by: groosha
2 Replies

9. Shell Programming and Scripting

permission, owner and group

hello I search a script (ksh for Aix 5.3) to save all permissions, groups and owner for all files. Because we work much to change it, and a mystake ......! So i want execute this script to save/ execute permissions for all files. If you have this script, thank you for your help ;) best... (2 Replies)
Discussion started by: pascalbout
2 Replies

10. UNIX for Dummies Questions & Answers

owner and group in Linux

I am bit unclear of how Linux was set in the real world, please advise me how it's supposed to be. When I log in as root and do a ls -l, I find: /boot, /, /var, /usr, /tmp, /home, /u01, /u02, /u03 and of of this partition is owned by root and the group also belong to root. Is that the way it's... (1 Reply)
Discussion started by: lapnguyen
1 Replies
Login or Register to Ask a Question