Back

Explore Courses Blog Tutorials Interview Questions
0 votes
2 views
in Linux by (18.4k points)

I am trying to create user accounts on theLinux (Fedora 10) and automatically assign a password using the bash script(or otherwise, if need be).

I don't find it difficult to create the user via Bash e.g.:

[whoever@server ]#  /usr/sbin/useradd newuser

Is it possible to assign the password in the Bash, something functionally similar to this, but automatically:

[whoever@server ]# passwd newuser

Changing password for user testpass.

New UNIX password:

Retype new UNIX password: 

passwd: all authentication tokens updated successfully.

[whoever@server ]#

1 Answer

0 votes
by (36.8k points)

You need to run the passwd command and send it the piped input. So, do something like:

echo thePassword | passwd theUsername --stdin

 Want to be a Linux expert? Come and join this Linux course

Related questions

0 votes
1 answer
0 votes
1 answer
0 votes
1 answer
asked Feb 4, 2021 in Linux by blackindya (18.4k points)
0 votes
1 answer
0 votes
1 answer
asked Dec 10, 2020 in Linux by blackindya (18.4k points)

Browse Categories

...