Skip to content

Instantly share code, notes, and snippets.

@Zenexer
Last active March 6, 2018 11:38
Show Gist options
  • Star 2 You must be signed in to star a gist
  • Fork 3 You must be signed in to fork a gist
  • Save Zenexer/5820858 to your computer and use it in GitHub Desktop.
Save Zenexer/5820858 to your computer and use it in GitHub Desktop.
#!/bin/bash
if [ $# -lt 1 ]; then
echo "Syntax: $_ USER[ USER[ ...]]" >&2
exit 1
fi
exit_code=0
for user in "$@"; do
home="/home/$user"
cp -R /etc/skel "$home" && echo $'\e[32m'"Copied skeleton to: $home"$'\e[m' || ( exit_code=$?; echo $'\e[31m'"Failed to create: $home"$'\e[m' ) >&2
chown -R "$user:$user" "$home" && echo $'\e[32m'"Set owner on: $home"$'\e[m' || ( exit_code=$?; echo $'\e[31m'"Failed to set owner on: $home"$'\e[m' ) >&2
done
exit $exit_code
@Zenexer
Copy link
Author

Zenexer commented Jun 20, 2013

# wget
wget https://gist.github.com/Zenexer/5820858/raw/userdir.sh
# curl
curl -o userdir.sh https://gist.github.com/Zenexer/5820858/raw/userdir.sh

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