node.jslinuxcentos7hubotyo

File execute permission keeps changing back in Linux


I am working as root and I have tried to change the permission of this file so I could read, write and execute but everytime I run 'yo hubot' it changes back.

chmod -v u=rwx /root/.config/configstore/insight-yo.json
mode of â/root/.config/configstore/insight-yo.jsonâ changed from 0400 (r----
----) to 0700 (rwx------)
[root@me configstore]# ll
total 8

The permission changes here

-rwx------. 1 root root 30 Jul 24 21:38 insight-yo.json
-rwxr-xr-x. 1 root root 55 Jul 24 21:24 update-notifier-npm.json

Then I run the "yo" command it throws an EACCES error

[root@me configstore]# yo hubot root/.nvm/versions/node/v6.11.0/lib/node_modules/yo/node_modules/insight/node_modules/configstore/index.js:53 root/.nvm/versions/node/v6.11.0/lib/node_modules/yo/node_modules/insight/node_modules/configstore/index.js:53

Error:

EACCES: permission denied, open '/root/.config/configstore/insight- yo.json' : You don't have access to this file.

    at Error (native)
    at Object.fs.openSync (fs.js:641:18)
    at Object.fs.readFileSync (fs.js:509:33)
    at Object.get

(/root/.nvm/versions/node/v6.11.0/lib/node_modules/yo/node_modules/insight/node_modules/configstore/index.js:34:26) at Object.Configstore.get (/root/.nvm/versions/node/v6.11.0/lib/node_modules/yo/node_modules/insight/node_modules/configstore/index.js:81:13) at Insight.get (/root/.nvm/versions/node/v6.11.0/lib/node_modules/yo/node_modules/insight/lib/index.js:48:22) at Object. (/root/.nvm/versions/node/v6.11.0/lib/node_modules/yo/lib/cli.js:194:47)

at Module._compile (module.js:570:32)
at Object.Module._extensions..js (module.js:579:10)
at Module.load (module.js:487:32)`

I check the file again and notices it changes back

[root@me configstore]# ll
total 8
-rw-------. 1 root root 30 Jul 24 21:45 insight-yo.json
-rwxr-xr-x. 1 root root 55 Jul 24 21:24 update-notifier-npm.json`

Solution

  • i figured out the problem was from 'yo' and not the file itself and 'yo' apparently can't be run as 'root' so ran 'yo' as another user and it worked without any errors.

    Thank you