for dir in /home/* do if [ -d "$dir" ] then username=$(basename "$dir") chown -R "$username:$username" "$dir" chown "$username":access "$dir" fi done