0

I just set up a apache server on my Raspberry pi. To make the development easier I shared the /var/www/html folder with samba.

I'm able to create new files from my computer in the Pi folder, but they have the following permission : -rwxrw---- 1 pi pi 52 juin 10 17:54 test.php

With those permissions Apache is not able to read the file.

So each time I need to send the following command to make the file readable by Apache : chmod a+rwx test.php

Then my permission are : -rwxrwxrwx 1 pi pi 52 juin 10 17:54 test.php

So ok, after sending this command, it's works... But I am trying to find the command to set up the default file permissions to "-rwxrwxrwx " I'm new with linux so maybe it's easy to fix.... Do you have any ideas ?

Thanks a lot, Maxime

Dommax
  • 21
  • 2
  • Possible duplicate of [How to set system wide umask?](https://stackoverflow.com/q/10220531/608639), [Setting default permissions for newly created files and sub-directories under a directory in Linux?](https://stackoverflow.com/q/580584/608639), [How to set umask in UNIX in a way that default file permission is rwx?](https://stackoverflow.com/q/40684924/608639), [How to set umask default for an user?](https://stackoverflow.com/q/30752103/608639), etc – jww Jun 10 '19 at 18:05

3 Answers3

1

Thanks for your answers.

the solution was to change the "create mask" value to 0775 in the smb.conf file.

Maxime

Dommax
  • 21
  • 2
0

The default umask value is 0022, which decides the default permission for a new file or directory. The default permission for a directory is 0777, for files the permissions are 0666 from which the default umask value 0022 is deducted to get the newly created files or directory permission.

0

For changing default permissions of the file created, you can use umask command. umask is user mask which is used whenever a new file is created.

umask is a three digit number with octal base. First digit decides the user permissions, second is for group while third determines the permissions for others.

umask value is used in inverted/complemented form though. That means to determine the required umask value for the permissions you want, subtract the permissions (in octal form) from 666. The result should be used as your umask value. e.g. if you want to set default permissions to rw-r--r-- (which is 644 in octal) subtract 644 from 666. The result (022) is your umask value.

To set value for umask you can simply use:

umask 022

command.

For your case here, I think you can use

umask 000
  • Thanks for you answer. after sending "umask 000" if I create a file from the console by typing "touch test.php" it's works perfectly with the new default permissions "-rw-rw-rw-". But if I create the file from my computer the permissions are -rwxrw---- and so I does not works..... Do you have an idea why ? Thanks – Dommax Jun 10 '19 at 16:36