Ubuntu – Import users from CSV file


Is it possible to import users by using CSV file? or something like a LDAP connection to import all users?

Best Answer

There's an app for that! The newusers tool which is part of the passwd package is designed to batch create users:

   The newusers command reads a file (or the standard input by default)
   and uses this information to update a set of existing users or to
   create new users. Each line is in the same format as the standard
   password file (see passwd(5)) with the exceptions explained below:

You will need to create a file with this format:

username:passwd:UID:GID:full name,room number,work phone,home phone,other:directory:shell

Many of these can be ignored and the default values will be used. You only need to specify the username and password. For example:


If I save that as users.txt and run this command:

sudo newusers < users.txt 

The users are created:

$ grep -E 'tom|danny' /etc/passwd
Related Question