I am new to linux and AWS.  I have a node.js server running on an EC2 instance. I am running the following command to keep it running endlessly and on port 80: $ sudo node app.js &Now when I run it using sudo my node application will not find any of the environment variables.I need to be able to set environment variable USER, PASSWORD, and an IP to connect to my database.  I have tried countless commands and only managed to set 1 environment variable but it gets deleted when I set a new variable.SOLUTIONI found what I was looking for thanks to the example Jeff Schaller gave below. I tried it exactly as it was but I'm not sure why it didn't work,  I ended up learning a bit on shellscripts.First I ran $ vim runapp.sh.  Then I added the following code :#!/bin/shClearexport USER=Usernameexport PASSWORD=Passwordexport IP=1.1.1.1Node ./bin/wwwAfter I saved the file, I ran $ chmod +x runapp.shFinally I ran $ sudo ./runapp.sh & and it ran perfectly.If I should not be doing this or if there is an error or a better and safer way of doing it let me know so that I can fix it eventually. 
Pass Environment Variable to Sudo AWS ec2 sudo node
sudo;environment variables;amazon ec2;node.js
Create a file like the following:#!/bin/shUSER=u PASSWORD=p IP=10.10.10.10 node app.js... or ...#!/bin/shUSER=u; export USERPASSWORD=p; export PASSWORDIP=10.10.10.10; export IPnode app.js... where you put your own values in there instead of u, p, and 10.10.10.10. Save the file as, say, runapp, then make it executable with chmod u+x runapp, then you run it:sudo ./runapp &