Created
September 13, 2016 13:14
-
-
Save rjsalts/4dc37ab46e943f890c41ef12b34b4915 to your computer and use it in GitHub Desktop.
when you update passwd/group/shadow
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
for user in $(getent passwd | sort -t : -k 3 -n | cut -d : -f 1,3);do if [[ $(grep ${user%%:*} passwd | cut -d : -f 1,3) == ${user} ]];then echo $user is the same;else find / -xdev -user ${user%%:*} -print0 > change_owner/${user%%:*};fi ;done | |
for group in $(getent group | sort -t : -k 3 -n | cut -d : -f 1,3);do if [[ $(grep ${group%%:*} group | cut -d : -f 1,3) == ${group} ]];then echo $group is the same;else find / -xdev -group ${group%%:*} -print0 > change_group/${group%%:*};fi ;done | |
cd change_owner;for file in *;do cat $file | xargs -0 -I '{}' chown $file {};done;cd .. | |
cd change_group;for file in *;do cat $file | xargs -0 -I '{}' chgrp $file {};done;cd .. |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment