![]() Thanks to everyone in the world who helped me with this script. Read -rsp $'Press any key to exit.\n' -n1 key If you want to configure sudo for an existing user, skip to step 3. | sudo xargs sed -i 's/$olduser/$newuser/g' home/$newuser/Ĭhown -R -from=$olduser $newuser:$newuser /home/$newuserĮcho "Now we are going to change the names of files and folders to the new user" This means that they will only be able to modify files in their own home directory, which is what we want. ![]() When run with no user specified, su will default to the root account. It lets you run a command as another user, provided you know that user's password. The su command exists on most unix-like systems. Read -rsp $'Ready to copy home folder - or ctrl-c to exit.\n' -n1 key Read the sudoers man page for more information use sudo visudo to edit the sudoers file. # change to the directory and run this commandĮcho "this script will create a new user"Įcho "You will be shown a list of users who can currently log on"Įcho "Remember which user you would like to clone."Įcho "You will be asked for the new user's name, their password"Īwk -F'' '' /etc/passwdĮcho "We are now going to copy the old user's home folder to the new user"Įcho "then change ownership to the new user" You are responsible for any code you copy - make backups! #!/bin/bash Watch out if you have a huge old user's home directory. To get the password to work I had the create a new line: echo $newuser:$newpassword | chpasswd.Īnother difference is that I couldn't get -create-home to work so I just used mkdir in a new line instead. The main difference in my script regarding the useradd line is that the passwd fails in Linux Mint 18, replaced by chpasswd. Based on Mike Anderson's script, I made one that asks questions about the new user, the old user, the new password, and then copies the old user's home directory and replaces all instances of the old user's name in the new home directory with the new user's name.
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |