Search code examples
linuxscriptingpermissionsdirectory

Changing file permissions automatically


At the moment, I paste files to a directory in Linux and it sets the following permissions:

rwxr--r--

What I'm trying to do is to set the permission to

rwxrw-r-- (group write)

automatically when I paste a new file into that folder or after a given period, preferably the one more efficient.

There must be an elegant solution to that already, if so can you point me the direction, please?


Solution

  • These "default rights" are called "umask" in the UNIX world (see wiki).

    I think your problem can be solved by appending a umask command to the /etc/profile script:

    umask 013
    

    Depending on your distributive, there can also be other ways to set umask.