Skip to content

Instantly share code, notes, and snippets.

@mdengler
Forked from booyaa/gist:3944974
Created October 24, 2012 09:06
Show Gist options
  • Save mdengler/3944990 to your computer and use it in GitHub Desktop.
Save mdengler/3944990 to your computer and use it in GitHub Desktop.
fixperms.sh
#!/bin/sh
set -e
set -x
for dir in /home/*; do
username=`basename "$dir"`
users_group=`id --group $username`
chown -R $username:$users_group $username
done
@jfautley
Copy link

awk -F: '($3 >= 1000) { printf("%s:%s:%s:%s\n", $1, $3, $4, $6) }' /etc/passwd | while read line; do
UNAME=$(echo $line | cut -d: -f1)
USERID=$(echo $line | cut -d: -f2)
GRPID=$(echo $line | cut -d: -f3)
HMDIR=$(echo $line | cut -d: -f4)

echo "Changing user [$UNAME] with home [$HMDIR] to [$USERID:$GRPID]"
#chown -R $USERID:$GRPID $HMDIR

done

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment