Change users umask - FreeBSD

Posted 1 year, 5 months ago at 8:14 pm. 0 comments

If you want to have safe shared hosting u will definitely change some user permissions and the UMASK.

Let me first explain what the umask is:

UMASK is an unix env variable which automatically sets file permissions on newly created files.

By default it is set to 022, which means it creates newly created files with permissions 755. (More about permissions - File system permissions)

Now if we want to set user permissions to 700 , we will change that default umask to 007 for this particular user.

Here is the command to set up users class:

pw usermod username -L someclass

Add this line to /etc/login.conf:

someclass:
	:umask=007:
	:tc=default:

Run the command:

cap_mkdb /etc/login.conf

to rebuild database.

Now were set, login to macihne as user “username”:

ssh username@box

Create some random directory:

[username@box ~]$ mkdir smth

And the directory permissions should look like this:

[username@box ~]$ ls -al | grep smth
drwx------  2 username  username    512 Feb 16 19:04 smth
[username@box ~]$

If you want to have different permissions, just change the value in /etc/login.conf “:umask=007:” to one that fits to you. More about UMASK - UMASK.

D.