Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I want to set the default permission for all files in a folder, including newly uploaded ones, to a certain value, say 644, instead of doing "chmod 644" all the time.

Is there any command making this possible?

share|improve this question

Alternatively, you can set the umask for all sftp logins in sshd's config file (/etc/ssh/sshd_config on my Debian box). For that add -u 022 to the sftp subsystem line like so:

Subsystem sftp /usr/lib/openssh/sftp-server -u 022

From man sftp-server:

-u umask
     Sets an explicit umask(2) to be applied to newly-created files and directo‐
     ries, instead of the user's default mask.
share|improve this answer

The permission files are created with depends on your umask. To get 644 permissions, set your umask to 022 (umask 022).

To make this change permanent, put that command in the remote servers ~/.profile (depending on your shell).

share|improve this answer
I searched umask and got the idea of that. But I still don't know where to change/edit that value. Can you give me more hints? – user866435 Sep 6 '11 at 0:27
In the remote servers ~/.profile, most likely. Simply add the line umask 022 at the very bottom (in most cases). – Ingmar Hupp Sep 6 '11 at 0:29
sorry, but I can't find the file .profile under the folder. Do I just create one? – user866435 Sep 6 '11 at 0:34
@user: Yes, just create one. (However, note that if ~/.bash_profile exists, then ~/.profile will be ignored.) – grawity Sep 6 '11 at 7:39

The .profile will be in the home directory for your user account. When ssh in you're going to be in your home directory, but you can also cause the shell to change to your home directory by typing:


If you're on linux and your user shell is bash, as most people are, you probably won't have a .profile, but you may have a .bash_profile and .bashrc. Set the umask in either of those files rather than make a .profile.

share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.