Add group to the user with -a (append to the group list)
sudo usermod -a -G vboxsf harvey
To close the user create a script like this
harvey@hvb:~/hscripts$ vi clone-user.sh
#!/bin/bash
SRC=$1
DEST=$2
BLANK=" "
BLANK=" "
SRC_GROUPS=$(id -Gn ${SRC} | sed "s/${SRC}${BLANK} //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}
run it to clone
Syntax
sudo ./clone-user.sh source_user target_user
It will ask the password for the new user
sudo ./clone-user.sh harvey michael
Done!!!
No comments:
Post a Comment