Tutan Ramen
Tutan Ramen

Reputation: 1252

Node - "mkdir /var/log/some_dir" Permission Denied

I am creating a node.js persistent logger. I want to create a directory for logging under /var/log and get the permission denied, because I am running under my user.

My question is, when creating this directory in node what is the generally accepted approach? Should I be doing a sudo command and having the user putting in their password if the dir needs to be created?

Upvotes: 1

Views: 2844

Answers (1)

Antfie
Antfie

Reputation: 61

Is it possible for you to create a directory under /var/log and assign permissions to yourself for that, as a one-off sudo that could perhaps also be in your setup instructions. it's not great or at all secure to have to use sudo before running commands, but it's okay for setting up.

Once the permissions are configured you should be fine. Essentially try not running the app as root. Also consider if your logs do in fact need to be in that location. Just some suggestions.

Upvotes: 1

Related Questions