Setting server-wide Umask for directories and files

April 4, 2017 175 views
Linux Basics Ubuntu

For the domains/sites running on my Ubuntu 14.04 server, I had added the Linux user accounts to the www-data group. The document root (public_html) of the individual Linux user accounts that correspond to each web site are chowned to user:user.

Now, when directories or files are created through SFTP or shell, they have 775 and 664 values. Is there a way to set the umask server-wide so that all directories have 755 as default and all files have 644 as the default?

Thanks in advance.

1 Answer

To set the system wide default umask for all user you need to make the below configuration in your need to add the below configuration in /etc/profile to have newly created directory having 755 and file having 644 permission.

umask 0022

Noe logoff the session and check the newly setup umask using usmak command.

Note:Note that users may still override umask in their own ~/.profile or ~/.bashrc or similar, but (at least on new Debian and Ubuntu installations) there shouldn't be any overriding of umask in /etc/profile or /etc/bash.bashrc. (If there are, just remove them.)

Hope it will help you.

Have another answer? Share your knowledge.