Skip to content
Node.js module to manage /etc/passwd
Find file
Latest commit 46ee7f6 @pkrumins update package.json
Failed to load latest commit information.
index.js fix .get bug
package.json update package.json
readme.txt updated readme


This is a node.js module for controlling /etc/passwd. I needed to do that
in my startup.

It was written by Peteris Krumins (, @pkrumins on twitter).
His blog is at  --  good coders code, great reuse.


Here is an example usage:

    var passwd = require('passwd');

    // add a new user (calls `useradd -m -p shadowPass pkrumins`)
    passwd.add('pkrumins', 'password', { createHome : true }, function (status) {
        if (status == 0) {
            console.log('great success! pkrumins added!');
        else {
            console.log('not so great success! pkrumins not added! useradd command returned: ' + status);

    // calls `userdel pkrumins`
    passwd.del('pkrumins', function (status) { ... });

    // locks user pkrumins via `usermod -L pkrumins`
    passwd.lock('pkrumins', function (status) { ... })

    // unlocks user pkrumins via `usermod -U pkrumins`
    passwd.unlock('pkrumins', function (status) { ... })

    // gets 'pkrumins' user entry from /etc/passwd
    passwd.get('pkrumins', function (user) { ... })

    // gets all users from /etc/passwd
    passwd.getAll(function (users) {
        users.forEach(function (user) {

That's it.


Peteris Krumins (twitter: @pkrumins)

Something went wrong with that request. Please try again.