How to create users on a Linux system in batches with the newusers command.

Posted: August 24, 2013. At: 9:47 PM. This was 4 years ago. Post ID: 6161
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.

The newusers command available on Linux allows you to create users in batches. This could also be automated with a shell script and quickly done on a new system that is to be shared by many users.

anders:754787547:1500:1500:Anders Smith:/home/anders:/bin/bash
johnc:4767577474:1501:1501:John Citizen:/home/johnc:/bin/bash
akmed:4565y4gr454h:1502:1502:Akmed Islam:/home/akmed:/bin/bash

Above is the list of new users. This is written out in the same format as the /etc/passwd file and contains all of the information about the new users.

Put the above information into a file named users.txt and then type this command as root to add them to your system.

newusers users.txt

This will create all of the users that you have defined in the users.txt file. Just make sure there is no newline at the end of the file or you will get an error.

After that; type cat /etc/shadow as root and you will see your newly created users at the bottom.


And here they are in the /etc/passwd file.

anders:x:1500:1500:Anders Smith:/home/anders:/bin/bash
johnc:x:1501:1501:John Citizen:/home/johnc:/bin/bash
akmed:x:1502:1502:Akmed Islam:/home/akmed:/bin/bash

That is how easy it is to create a bunch of new users on your Linux system. Try it yourself and see.

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

Leave a Reply