Ask Ubuntu is a question and answer site for Ubuntu users and developers. It's 100% free.

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 have a directory and I want all files that are put in it to have the permissions of **5. In other words I want the permissions of the owner and group to stay the same but the permission to be read and execute for all other users.

Is this possible? I know I can periodically set the permissions of all the files in this folder but I was wondering if there was a way to automate it.

share|improve this question
up vote 2 down vote accepted

You may want to take a look at umask:

umask (user mask) is a command and a function in POSIX environments that sets the file mode creation mask of the current process which limits the permission modes for files and directories created by the process. A process may change the file mode creation mask with umask and the new value is inherited by child processes. When a shell (as with an output redirect) or other program creates a file or directory, it may specify permissions to be granted, however, permissions that the file mode creation mask does not allow are removed.


Just set the desired umask mode at the beginning of your bash script to achieve the described effect.

share|improve this answer
Thanks man, I appreciate it. See, I have samba on my linux server and when I put files from my windows comp into the share folder, the umask mode changes the permissions as I desired. However when I put files from my linux comp (the server) into the share folder, the permissions don't change – user784637 Dec 18 '11 at 0:44
You could try mounting the folder in your server to a virtual path with the bind option while setting the umask for that bind mount. Then only put files into the bound path instead of the actual folder, i.e. mount --bind -o umask=0117 /home/files/smbfolder /home/files/virtualfolder – bkzland Dec 18 '11 at 10:54

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.