Posted: . At: 9:09 AM. This was 8 years ago. Post ID: 9462
Page permalink. WordPress uses cookies, or tiny pieces of information stored on your computer, to verify who you are. There are cookies for logged in users and for commenters.
These cookies expire two weeks after they are set.

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.

root@neo:/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.

root@neo:/home/jason# usermod --password `perl -e "print crypt('password01','sa');"` randycole

To delete a user, use the userdel command.

root@neo:/home/jason# userdel brian

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

Leave a Comment

This site uses Akismet to reduce spam. Learn how your comment data is processed.