I did a time shift backup restor, but now in various place I find users or groups that don't exist. they look like User #1034 group #1010 or user #501, and I am supossing this is why many things are not working Like TCP port 80 so my server is no longer accessable How do I find and fix these errors? fsck. I did a find find -user 1034|more, but this takes too much browsing. Perhaps a better expresion like I have used for permissions

find . -user old-user -exec chown new-user:new-group {} \; or sudo find . -type f ! -user 501 -exec chown 0 {} \;

, but how do I get an output to confirm?

What I would really like is a page on how to sting these expresions in one place as help does not give all operators and I have to brows all over to find the different parts at leat for file maniputations and grep things

  • You should be able to use the -nouser and -nogroup tests to find files for which no user/group corresponds to file's numeric group ID (rather than having to iterate over a list of numeric IDs explicitly) – steeldriver Oct 21 '17 at 18:11

If I understand correctly, the following can work for you

Create command lines with more than one -exec part according to the following example, the first part to show target-file:, and the following part(s) to perform the action(s).

$ sudo find /home/sudodus/Backup/ -user sudodus -exec printf "%s:\n" {} \; -exec echo do-this {} \; -exec echo do-that {} \;
[sudo] password for nio: 
do-this /home/sudodus/Backup/
do-that /home/sudodus/Backup/
do-this /home/sudodus/Backup/5
do-that /home/sudodus/Backup/5
do-this /home/sudodus/Backup/7
do-that /home/sudodus/Backup/7
do-this /home/sudodus/Backup/6
do-that /home/sudodus/Backup/6
do-this /home/sudodus/Backup/4
do-that /home/sudodus/Backup/4

where you can replace /home/sudodus/Backup/ with the relevant directory, that you want to search; -user with -nouser, -group, -nogroup; sudodus with the relevant user or group; echo do-this and echo do-that with the relevant commands. This way you can create command lines, that will do what you want and show which files that will be affected.

-nouser, -nogroup have no parameter, the command can look like this

sudo find /home -nouser -exec printf "%s:\n" {} \; -exec echo do-this {} \; -exec echo do-that {} \;

It is a good idea to start with echo as a 'dry run' to show that the correct things are likely to happen, and after that remove the echo parts of the commands to perform the action(s).

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.