How can you set Default Permissions for a specific directory using Linux (Ubuntu)?
I'm having trouble with default file/directory permissions using Linux. I know that the default is 0022, and you can change it using umask.
When I create a file, 0022 gives me:
-rw-r--r--
What I want is:
-rwxr-xr-x
Directories work. They show up as:
drwxr-xr-x
Using FileZilla (FTP client), if I right-click an item and change the permissions to "755", I get the desired effect. However, if I try "umask 755" in Linux, I get the following after creating a file via VI:
-----w--w-
And directories start showing up as:
d----w--w-
In the end, I just want all of the sub-folders in /var/www/ to be the only directories with these permissions, and I'd like to keep the root default to 0022. Can someone assist?
The umask is opposit of permssions i.e. the umasked permissions are taken away. The lowest umask you can set is 0000 and that would result in -rw-rw-rw- for the files and -rwxrwxrwx for the directories. The max permissions for file is 666 and for directories is 777. So with umask you can't create a file with 755 (-rwxr-xr-x).
umask works as followsDirectories will be created with the umask subtracted from 0777HOWEVER, files will be created with the umask subtracted from 0666Thus if you umask 0222 files will be created with r--r--r-- (0444) while directories will be created with dr-xr-x-r-x (0555)umask 0022 should work fine for you.
Basically you can't create a executable file by default (by setting umask) i.e. you need to make a file executable explicitly.
0
Featured Post
Get a firm grasp on your IT environment when you learn Active Directory best practices with Veeam! Watch all, or choose any amount, of this three-part webinar series to improve your skills. From the basics to virtualization and backup, we got you covered.