Get Even More Visitors To Your Blog, Upgrade To A Business Listing >>

Using nodejs chmod 777 and 0777

Using nodejs chmod 777 and 0777

Problem

Using fs.chmod(path, mode, callback) I set the mode to 777. It didn't work properly. But when I set it to 0777, it worked.

So I want to know what the difference is between chmod 777 and chmod 0777?

Problem courtesy of: Yofine

Solution

The leading zero in 0777 means that the number is an octal number.

The number 777 in octal notation is the number 511 in decimal notation. fs.chmod(path, 0777) and fs.chmod(path, 511) do the same thing, but fs.chmod(path, 777) does not.

The reason for your confusion is that you assumed the file access mode 777 is a decimal number. You might want to read more about the unix chmod program and file system permissions.

Solution courtesy of: Robert Kajic

Discussion

View additional discussion.



This post first appeared on Node.js Recipes, please read the originial post: here

Share the post

Using nodejs chmod 777 and 0777

×

Subscribe to Node.js Recipes

Get updates delivered right to your inbox!

Thank you for your subscription

×