Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

181
Views
running nodejs non root

I have added a line to /etc/rc.local that starts a node process after reboot:

/usr/local/bin/node /home/ubuntu/app/index.js &

the problem is that the process is running as root.

How can I specify non-root user to run the node process as?

over 4 years ago · Santiago Trujillo
3 answers
Answer question

0

Telling the system to run your process as a different user than root would be a question more suitable for the Ubuntu Forums or the Unix SE site.

As to how to change the user to a non-privileged user from within the Node.js process, you can use process.setuid() and process.setgid() to change the user and group IDs, respectively.

Note that once you change these to non-root values, you cannot go back to the elevated root privileges.

over 4 years ago · Santiago Trujillo Report

0

I would try this, but I haven't tested it in your context:

exec sudo -u nodejs /usr/local/bin/node /home/ubuntu/app/index.js &
over 4 years ago · Santiago Trujillo Report

0

You can run it with another user with this line:

su -c "/usr/local/bin/node /home/ubuntu/app/index.js" & -s /bin/sh <username>
over 4 years ago · Santiago Trujillo Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!