Thursday, February 02, 2023

Write a bash script to add a new user called deploy and give it a password

 Here is a script in Bash that adds a new user deploy and sets a password for it on an Ubuntu system:

#!/bin/bash # Variables for the new user and password username=deploy password=<new_password> # Add the new user sudo adduser $username # Set the password for the new user echo "$username:$password" | sudo chpasswd Replace the placeholder <new_password> with the desired password for the deploy user. Then, save the script to a file and make it executable with the chmod +x command. You can then run the script from the terminal. Note that this script assumes that you have sudo privileges on the system.