Skip to content

Instantly share code, notes, and snippets.

@zuckercode
Created September 14, 2012 08:27
Show Gist options
  • Star 2 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save zuckercode/3720747 to your computer and use it in GitHub Desktop.
Save zuckercode/3720747 to your computer and use it in GitHub Desktop.
add new user with zsh as default shell
#!/bin/bash
read -p "please provide a name for a new user:" name
if [ "$name" == "" ]; then
echo "You did not entered a user name, so no user will be added after setup"
fi
USER=$name
HOME=/home/$USER
echo "Add user $USER"
adduser $USER --disabled-login
echo "generate .ssh dir in homedir for user $USER"
mkdir $HOME/.ssh
chmod 0700 $HOME/.ssh
echo "clone zsh git repo in $USER homedir"
git clone git://github.com/robbyrussell/oh-my-zsh.git $HOME/.oh-my-zsh
chmod 0755 $HOME/.oh-my-zsh
echo "setup default zsh settings"
cp $HOME/.oh-my-zsh/templates/zshrc.zsh-template $HOME/.zshrc
chmod 0755 $HOME/.zshrc
echo "set correct permissions"
chown -R $USER:$USER /home/$USER
echo "change shell for user $USER"
chsh --shell /bin/zsh $USER
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment