Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to create a linux user using nodejs

I have seen npm adduser, but i can figure it out how to manage this inside mine code. What i have to do is to create new user from nodejs server code inside linux server, and change chmod and chown of that user and folders it content.

like image 947
Honchar Denys Avatar asked Nov 24 '25 20:11

Honchar Denys


1 Answers

Use child_process.execFile to execute /usr/sbin/adduser, /bin/chmod and /bin/chown

Otherwise you can use exec from npm if your version of nodejs doesn't have child_process.execFile

like image 134
Troy Avatar answered Nov 26 '25 11:11

Troy



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!