Last active
December 21, 2020 05:01
-
-
Save ryu1/7e1e98a0c47603c80891ec59636d2e75 to your computer and use it in GitHub Desktop.
There are shellscripts for changing ower of files or directories..
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
#/bin/bash | |
# Finds the object with the specified group ID and changes the owning group. | |
# _gid : Group ID that remains unchanged | |
# _grp : Group name you want to change | |
find_gid_and_chown_group() { | |
_gid=${1} | |
_grp=${2} | |
_buf_ifs=${IFS} | |
IFS= | |
find / -gid ${_gid} -print | \ | |
while read _path | |
do | |
if [ -d ${_path} -o -f ${_path} ]; then | |
# Change the ownership group of directories and files | |
echo "Change ${_path}" | |
chown .${_grp} ${_path} | |
elif [ -h ${_path} ]; then | |
# Change the owning group of the symbolic link itself | |
echo "Change ${_path}" | |
chown -h .${_grp} ${_path} | |
else | |
echo "No Change ${_path}" | |
fi | |
done | |
IFS=${_buf_ifs} | |
} | |
find_gid_and_chown_group $1 $2 |
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
#/bin/bash | |
# Finds the object with the specified user ID and changes the owning user. | |
# _uid : User ID that remains unchanged | |
# _usr : Username you want to change | |
find_uid_and_chown_user() { | |
_uid=${1} | |
_usr=${2} | |
_buf_ifs=${IFS} | |
IFS= | |
find / -uid ${_uid} -print | \ | |
while read _path | |
do | |
if [ -d ${_path} -o -f ${_path} ]; then | |
# Change the owner user of directories and files | |
echo "Change ${_path}" | |
chown ${_usr} ${_path} | |
elif [ -h ${_path} ]; then | |
# Change the owning user of the symbolic link itself | |
echo "Change ${_path}" | |
chown -h ${_usr} ${_path} | |
else | |
echo "No Change ${_path}" | |
fi | |
done | |
IFS=${_buf_ifs} | |
} | |
find_uid_and_chown_user $1 $2 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment