So I have a NodeJS app with a node module called linux-user
it just provides a api to view / change Linux users through javascript. In my app I just have it scanning and outputting what the userid is and the username for the linux host. I want to put this file into production but it requires the JavaScript file to be run as root to run. However I don't want someone to tamper with it without the proper permissions but still able to run without running the app as root when I call it. What is the process to change the ownership of this file?
The file must do this:
sudo
Probably not the best idea to give the script root user permission. This can do a lot of damage potentially. However, considering this is what you want to do, you need to change the owner to root and then set permission in a way so that only owner has write+execute permission In order to change the owner to root:
sudo chown root <filename>
Then you need to set the permission so that no one else can execute it by:
sudo chmod 740 <filename>
740 = Owner can read, write, excute; users in the same group can read; rest of the users can't read,write nor execute.