How to create a new user on Linux and add a password in one go.

The useradd command can create a new user on your Linux system. Here is how to add a password as well all in one simple operation.

[email protected]:/home/jason# useradd -m -s /bin/bash -g users -p $(openssl passwd -1 ff302) randycole

This is a good solution for adding a new user to a Linux system.

To change the user`s password, use the passwd command as root.

root@neo:/home/jason# passwd randycole
Enter new UNIX password: 
Retype new UNIX password: 
passwd: password updated successfully

This is another way to change a users password on a Linux system with the root prompt.

[email protected]:/home/jason# usermod --password `perl -e "print crypt('password01','sa');"` randycole

To delete a user, use the userdel command.

[email protected]:/home/jason# userdel brian

Adding and changing users this way is very useful. And could easily be used in a shell script.

No comments have been made. Use this form to start the conversation :)

Leave a Reply