Last active
October 23, 2024 14:03
-
-
Save dimti/31ba1974f97911b40b7c25482b282a1b to your computer and use it in GitHub Desktop.
Swap users uids
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
SITE_USER=mysiteuser | |
SITE_GROUP=$(id $SITE_USER | sed -E 's/.+gid=[[:digit:]]+\(([^)]+)\).+/\1/g') | |
PROJECT_DIR=/var/www/mysiteproject | |
BUTHEAD_USER=dimti | |
FROM_UID=1001 | |
TO_UID=1000 | |
INTERMEDIATE_UID=1002 | |
usermod -u $INTERMEDIATE_UID $BUTHEAD_USER && \ | |
groupmod -g $INTERMEDIATE_UID $BUTHEAD_USER && \ | |
usermod -u $TO_UID $SITE_USER && \ | |
groupmod -g $TO_UID $SITE_GROUP && \ | |
chown -Rh --from=$FROM_UID $TO_UID $PROJECT_DIR && \ | |
chown -Rh --from=:$FROM_UID :$TO_UID $PROJECT_DIR && \ | |
usermod -u $FROM_UID $BUTHEAD_USER && \ | |
groupmod -g $FROM_UID $BUTHEAD_USER |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment