Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

183
Visualizações
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 Respostas
Responde à pergunta

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 Relatório

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 Relatório

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 Relatório
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda