List files whose owner or group is numeric


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting List files whose owner or group is numeric
# 1  
Old 03-20-2018
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

Code:
find . \( -user root -o -user soham\)  -type f -exec ls -l {} \; 2>&1

---------- Post updated at 10:20 AM ---------- Previous update was at 09:47 AM ----------

Sorry the command is

Code:
find . \( -user root -o -user soham\)  -type f -exec ls -l {} \; 2>/dev/null

# 2  
Old 03-20-2018
Do you mean group id and user id for numbers?

Code:
cat /etc/group

will show you what numbers to use, /etc/passwd has userids.

Example: user john is uid 633 and group 101:
Code:
find . -type f   \( -user 633 -o -group 101 \)

will start you going.

Note that these numbers are usually not portable between servers, some uid's are constant like root, but john's uid could be almost any number > 100.

Edit: the id command will help, too.
Code:
id john

will show the uid and the group(s) for the user named john. Some users may be in multiple groups

Last edited by jim mcnamara; 03-20-2018 at 12:13 PM..
# 3  
Old 03-20-2018
We have some files/directory which are owned by/having group which are numeric. I want to add this condition in find command.

Thx
# 4  
Old 03-20-2018
If you have uid's/gid's showing as numeric in list (e.g. ls) commands then it's (probably) because those uid/gid have been removed (deleted) from either /etc/passwd (or /etc/shadow) and /etc/group respectively.

If you can reinstate the entries in those files then the system will translate them into human readable uid/gid and they will no longer appear numeric. They are only appearing numeric now because those numbers do not appear in the files and so cannot be made human readable. Perhaps the original owner's user account was deleted? Change the ownership of those files to a currently valid account.

Last edited by hicksd8; 03-20-2018 at 02:56 PM..
# 5  
Old 03-27-2018
If you are looking for files that belong to a userID or groupID that is not current in your system try -nouser or -nogroup

For example where userID 57484 does not exist in the system:
Code:
$ chown 57484:root mp.log
$ find . -type f \( -nouser -o -nogroup \) -ls
   397014      4 -rw-r--r--   1  57484    root          360 Mar 24 01:45 ./mp.log

These 2 Users Gave Thanks to Chubler_XL For This Post:
# 6  
Old 03-28-2018
Thanks. This is what I wanted. I do not know how I missed it from man pages !
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

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 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... (9 Replies)
Discussion started by: Soham
9 Replies

2. UNIX for Beginners Questions & Answers

UNIX command to display Owner,Group,Root and Subdirectories list

Hi Team, Am a newbie to Unix. As I would like to see the Server Name,Owner Name ( not numeric form), Group Name ( not numeric ID), ROOT path. I would like to send this list as an attachment to my personal mail. Can any one please help me out to to resolve this . Here is the sample result... (6 Replies)
Discussion started by: vasuvv
6 Replies

3. 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

4. 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

5. 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

6. 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

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. UNIX for Dummies Questions & Answers

How to copy owner permissions to group

Hi, I need a command or a script to change the group permissions to be the same as the owner permissions for all my files and directories (recursive) any idea ? (4 Replies)
Discussion started by: ynixon
4 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