Find the answer to your Linux question:
Results 1 to 7 of 7
Hello All, I have an application that creates the log files and they created with 600 permissions instead of 644(default). How can I set the permissions so that files can ...
Enjoy an ad free experience by logging in. Not a member yet? Register.
  1. #1
    Just Joined!
    Join Date
    Feb 2013
    Posts
    4

    set permissions for new files created by application


    Hello All,
    I have an application that creates the log files and they created with 600 permissions instead of 644(default). How can I set the permissions so that files can be created with 644. I looked into the /etc/profile for the umask settings and it is set 002(if UID>199).
    Also when I login with root and create file manually, it creates with 644. Could some one help me out . Thanks.

  2. #2
    Just Joined!
    Join Date
    Feb 2013
    Location
    Campinas (SP) Brazil
    Posts
    3
    Hello,

    did you use umask command to modify the permission default of theses files?

  3. #3
    Just Joined!
    Join Date
    Feb 2013
    Posts
    4
    Yes. I did but again no luck. I did use the umask 002 <directory>. Also when I file updated on size limit, permissions are resetting. Thanks.

  4. #4
    Just Joined!
    Join Date
    Feb 2013
    Location
    Campinas (SP) Brazil
    Posts
    3
    When you type the command umask (only umask), what is the response?

  5. #5
    Just Joined!
    Join Date
    Feb 2013
    Posts
    4
    it was 0022 and still it is 0022. Thanks

  6. #6
    Just Joined!
    Join Date
    Feb 2013
    Location
    Campinas (SP) Brazil
    Posts
    3
    Well, it is very strange! But, here we go...

    If your mask is 0022, your default permission should be 644 (rw- r-- r--) for new files and 755 (rwx r-x r-x) for new directories.

    How did I calculate this? Is very simple: subtract the umask from the base permissions to determine the final permission for files/directories:

    For FILES:

    File base permissions : 666
    umask value : 022
    subtract to get permissions of new file (666-022) : 644 (rw- r-- r--)


    For DIRECTORIES:

    Directory base permissions : 777
    umask value : 022
    Subtract to get permissions of new directory (777-022) : 755 (rwx r-x r-x)


    You can setup umask in /etc/bashrc or /etc/profile file for all users, just append/modify following command: umask <value>
    (It is not necessary to include the directory)

    Save and close the file. Changes will take effect after next login.
    All UNIX users can override the system umask defaults in their /etc/profile file, ~/.profile (Korn / Bourne shell) ~/.cshrc file (C shells), ~/.bash_profile (Bash shell) or ~/.login file (defines the user's environment at login)


    OBS: If you need to make permission changes to existing file use the chmod command.

    Source: nixCraft

  7. #7
    Just Joined!
    Join Date
    Feb 2013
    Posts
    4
    Thanks for the great explanation. I do understand it but what I didn't understand is why it is creating the files with 600 instead of 644 even though umask configured properly. Thats really strange. I did little bit of research on it and found that my application is over writing the permissions. So I just set up the cron job to run every 5mins to find any files created with 600 in that directory and change permissions to 644. But I'm not interested in running the cron job as I have to wait 5 or less minutes to read the file and I dont want to run it every min or so. I will have to check if there are any other options. Thanks.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •