Permissions problem

Discussion in 'Installation/Configuration' started by webwizzy, Mar 4, 2009.

  1. webwizzy

    webwizzy New Member

    Hello,

    1. All my folders are saving as 0775 by default, whereas they should be 0755 right?

    Similarly, all my PHP files save as 0664 by default, instead of 0644.

    How do I correct this problem?

    2. Another thing is that:-

    My folder structure is like this: /home/username/public_html

    /home/ is owned by root and is chmod 0755
    /username/ is owned by username and is chmod 0755
    /public_html/ is owned by username and is chmod 0755

    Are these permissions good? I mean are they secure enough?

    Thanks
     
  2. falko

    falko Super Moderator ISPConfig Developer

     
  3. webwizzy

    webwizzy New Member

    I am using just SFTP, and WinSCP as my SFTP client.

    I also tried creating a new php file from SSH while logged in as "username".

    It is giving 0664 to php files by default, instead of 0644. What should i do?

    Thanks
     
  4. webwizzy

    webwizzy New Member

    okay.. I found one thing.

    I notice that when I upload files from "username", only then 0664 and 0775 permissions are being given. However, this is not happening with "root". The file/folder permissions are correct if uploaded from root account.

    What should I do to make "username" upload files/folders as 0644 and 0755?

    And why did this happen when I simply created user like useradd username , it should have inherited default permissions, right?

    Thanks
     
    Last edited: Mar 5, 2009
  5. webwizzy

    webwizzy New Member

    OKAY.. I solved this problem after some crazy googling. I am sure someone setting up servers from scratch can face this problem too, so here's the solution.

    1. Connect to SSH as username.

    2. Edit the bashrc file:

    Code:
    vi .bashrc                 //this file resides in /home/username folder
    3. Add the following at the end of the file:

    Code:
    umask 022
    Save and close the file. Changes will take effect after next login. Thats it! :)

    Problem Description:-

    - The default umask 002 is used for normal user. With this mask, default directory permissions are 775 and default file permissions are 664. (This was the problem in my case)

    - The default umask for the root user is 022. With this mask, default directory permissions are 755 and default file permissions are 644. (Which I want for my username too)

    - For directories, the base permissions are (rwxrwxrwx) 0777 and for files they are 0666 (rw-rw-rw).

    To calculate directory permission for 022:
    Default Permissions: 777
    Subtract umask value: 022 (-)
    Allowed Permissions: 755

    To calculate file permission for 022:
    Default Permissions: 666
    Subtract umask value: 022 (-)
    Allowed Permissions: 644


    Thanks
     

Share This Page