Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Reset Linux Home directory permissions based on /etc/passwd
#!/bin/bash
chown root:root /home
chmod 755 /home
USERS=$(grep '/home' /etc/passwd | tr "\n" "\n")
for USER in $USERS
do
IFS=":" read -ra DETAILS <<< "$USER"
$(chown -R ${DETAILS[0]}:${DETAILS[0]} ${DETAILS[5]})
$(chmod -R 750 ${DETAILS[5]})
done
@willpower232

This comment has been minimized.

Copy link
Owner Author

commented Dec 13, 2017

If you are using a custom system that has home directories elsewhere, simply substitute /home for your home directories directory (e.g. /organisation/websites)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.