Question

Setting server-wide Umask for directories and files

Posted April 4, 2017 2.9k views
Linux BasicsUbuntu

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.

These answers are provided by our Community. If you find them useful, show some love by clicking the heart. If you run into issues leave a comment, or add your own answer to help others.

×
1 answer

To set the system wide default umask for all user you need to make the below configuration in your server.you 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.

Submit an Answer