Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

182
Vistas
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 Respuestas
Responde la pregunta

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 Denunciar

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 Denunciar

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 Denunciar
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda