Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #!/bin/bash
- # Author : Jobin Joseph
- clear
- echo "Script for renaming a User
- Use at your own risk"
- echo -n "Enter the current username: "
- read joldname
- echo -n "Enter the new username: "
- read jnewname
- echo "########################
- The user * $joldname * will be renamed to * $jnewname *
- Press ctrl+c to cancel, The commands will be executed in 10 seconds
- ########################"
- sleep 10
- # rename the user
- usermod -l $jnewname $joldname
- #rename group
- groupmod -n $jnewname $joldname
- #move home
- usermod -m -d /home/$jnewname $jnewname
- if [ $? -eq 0 ] ; then
- echo "########################
- The account has been renamed, Please update the sudeors file if the user has sudo access
- ########################"
- id $jnewname
- else
- echo "********* Something went Wrong !!! Please check the above error message *********"
- fi
- exit 0
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement