1856603 Members
15535 Online
104113 Solutions
New Discussion

Re: Change file mode

 
SOLVED
Go to solution
Cheung_2
Frequent Advisor

Change file mode

I want to create a directory to let some programs to put file on it, the programs will generate the files with the mode 644 into this directory , while other programs need to modify the file, but it can't cos the mode is 644 ( 4 is only for read ) , how to force the mode of the all files when writing to these directory are 666 ? thx.
Andy
9 REPLIES 9
U.SivaKumar_2
Honored Contributor
Solution

Re: Change file mode

Hi,

use umask
#man umask

Also you can change permissions of all files under a directory with
chmod -R

regards,
U.SivaKumar
Innovations are made when conventions are broken
Rajeev  Shukla
Honored Contributor

Re: Change file mode

Since your application is creating files with 644 use umask before running the application which generates the files or use umask in the profile.
umask 02 creates files of 664 and 01 creates with 666
workout what u want

Cheers
Rajeev
Cheung_2
Frequent Advisor

Re: Change file mode

I just want to change the type of file , so i don't want to change the user profile. Thx.
Andy
T G Manikandan
Honored Contributor

Re: Change file mode

By default the permission of files are like

directories and exe's 777 -rwxrwxrwx
other files 666 rw-rw-rw-

i.e.the umask being 000.

When you have umask as 022 then you have

directories as 755 and files as 644

(subtracting 022 from 777 and 666)
So if you need to create files with 666 permission by default then it should be umask 000.

But make sure this makes the files to have access to everyone.(Beware!)
Cheung_2
Frequent Advisor

Re: Change file mode

I just want to change the type of file , so i don't want to change the user profile. Thx.

If i change the umask in the profile, then the mode of all files (whateven directory) will be changed , I only want to change the mode in one directory , what can I do? Thx.
Andy
Cheung_2
Frequent Advisor

Re: Change file mode

I can do it now , Thx all
Andy
U.SivaKumar_2
Honored Contributor

Re: Change file mode

please tell us what is the solution and encourage the people who helped you by assigning points
Innovations are made when conventions are broken
Rajeev  Shukla
Honored Contributor

Re: Change file mode

can you please tell us all whether you got your poblem fixed, if yes how?

good luck
Rajeev
Bill Hassell
Honored Contributor

Re: Change file mode

umask will affect all subsequent files. umask 000 will allow your files to be created with 66 permissions but that means that everyone that has a login can trash the contents of these files.

Rather than open the permissions that allow corruption, use chmod to change the files to 664 and make the owners of the other programs part of a group. That way, only members of that group will have write permissions.


Bill Hassell, sysadmin