Created
June 10, 2019 16:04
-
-
Save reinaldocoelho/4d464dc892444be355770aacb3b247e6 to your computer and use it in GitHub Desktop.
Clonning ubuntu user.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
## Sugestion #1 | |
# on Bash | |
sudo bash | |
# Home origin user | |
cd /home/bob | |
# Clone home folder | |
tar cf - . | (cd ../pete;tar xf -) | |
# Change home permissions | |
chown -R pete:pete /home/pete | |
## Sugestion #2 | |
#!/bin/bash | |
SRC=$1 | |
DEST=$2 | |
SRC_GROUPS=$(id -Gn ${SRC} | sed "s/${SRC} //g" | sed "s/ ${SRC}//g" | sed "s/ /,/g") | |
SRC_SHELL=$(awk -F : -v name=${SRC} '(name == $1) { print $7 }' /etc/passwd) | |
useradd --groups ${SRC_GROUPS} --shell ${SRC_SHELL} --create-home ${DEST} | |
passwd ${DEST} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment