I'm trying to find the way to use adduser this way:adduser $username $passwordor something like this too:adduser -u $username -p $passwordI know I could use useradd and so, but right now I want to use adduser.Thanks!
How to use adduser command with a bash script
bash
There is no way to specify the password to adduser on the command line. The only way to script it is to supply the password (and confirmation) to stdin, just as happens when the program interacts with the user. Here is an example using a here document:adduser $username <<EOF$password$passwordEOFAlso note that if the password could be supplied as an argument, this would be the most insecure way to do it. While the command is running, the arguments can be read by all users. At least this way if the script is only readable by root, then the password won't be readable by everyone.UpdateActually here documents can create temporary files, which would contain the password. The most secure approach seems to be to use echo and a pipe (and to ensure 700 permissions for the script):echo $password$password | adduser $username