Set umask for another user

October 26, 2016 10.1k views
Security Ubuntu 16.04

I have two users who are only ftp users I set them up using this guide

I would like to change their default permissions when creating files to 775 instead of 755.

It seems like what I want is umask.

But umask doesn’t have an option to set for another user, only the logged in user (umask 002) and these users do not have ssh login, only ftp access.

So I need some way of changing the umask of these users as root or sudo.

There appears to be ~.profile but I changed the settings in here and it didn’t make a difference

Can anyone explain where I can change the umask for these users?

3 Answers

You can try ~/.bashrc beside ~./profile.

  • sudo nano /home/user/.bashrc

Add line:

umask 002

Save file, exit and try again.

Also you can try to execute command as another user:

Sample command
su -c "command" user

In your case:

  • su -c "umask 002" user

I’ve just edited .bashrc logged in with ftp as the user and uploaded a file and it still gets created as 755 rather than 775.

Presumably it’s something to do with the fact that it’s using ftp rather than ssh/bash, although I don’t really understand the way in which the two are different/similar.

In order to change the umask for a user you can use the following command:

sudo chfn -o umask=007 username

Experiment with the umask value in order to suit your needs :)

  • I got the following error message. Any idea how to escape equal sign with the command ?

    chfn: Office: '=' is not allowed

    The linux distro is CentOS Linux 7 (Core)

Have another answer? Share your knowledge.