Dear Ralph,

Great! Thank you very much for the tips!

Yours sincerely,

Xianwen

On 08/09/2019 15.11, Ralph Corderoy wrote:
Dear Xianwen,

there are quite many files on my system that had wrong permissions or
GID's.
Perhaps there's been an errant recursive chmod or chgrp in the past by
root.

Is there a way to automatically correct all the permissions and GID's?
Others like Eli might know an mtree-specific way, but if there's a
common feature, like lots of files under /usr/bin that are group xianwen
instead of root, then find(1) could be used to first list what it would
change, allowing the list to be checked by eye, and then correct.
Something like

     find -xdev /usr/bin -group xianwen -ls
     find -xdev /usr/bin -group xianwen -exec chgrp root {} +

https://mywiki.wooledge.org/UsingFind might help if you're not familiar
with find(1).  It has -user and -perm too.

Or you could try and use the output of paccheck(1) to produce a script
to execute, again after checking it by eye.

     sudo -i paccheck --quiet --file-properties |
     awk '
             / permission mismatch / {
                 print "chmod 0" substr($6, 1, length($6)-1), $2
             }
         '

Reply via email to