1833017 Members
2178 Online
110048 Solutions
New Discussion

User mode

 
SOLVED
Go to solution
hangyu
Regular Advisor

User mode

We have a common directory , now we want all the files under this directory are mode 664 because we want all users in the same group can delete it , but the umask we set is 0022 , so the new files are in 644 mode when the user newly create it , how to make sure all files ( include hidden files ) are mode 664 ? But I think set a crontab job is not work because the time interval is 1 minutes , is there other suggestion ? thx
7 REPLIES 7
Warren_9
Honored Contributor
Solution

Re: User mode

hi,

change the umask to 0002.

GOOD LUCK!
morganelan
Trusted Contributor

Re: User mode

umask only masks the default file and directory permissions

default file permission: -rw-rw-rw
default dir permission: -rwxrwxrwx

if you apply umkas of 022

access permissions of the new file created would be = 666 - 022 = 644 (rw-r--r--)

for dir = 777 - 022 = 755 (rwxr-xr-x)

If you need to set an executable bit from a shell created file, you must issue an explicit chmod after first creating the file.

Kamal Mirdad
hangyu
Regular Advisor

Re: User mode

thx replies,

I understand set the umask can change the file permission , but if change it , all the user created files are in the new mode ( 664 ) , I just want the files in the specific directory is 664 , not all the files in the system , could suggest how to make it ? thx.
Devesh Pant_1
Esteemed Contributor

Re: User mode

Hangyu,

To achieve what you want the only way is to run a cron job and you will have to bear with the 1 minute delay because umask is for the id only and not for the filesystem

thanks
DP
morganelan
Trusted Contributor

Re: User mode

You must create a shell script that touch the new files in certain folder and then issue chmod 664 * command in that script.

example script file:

#!/bin/ksh
touch /newdir/new-file
chmod 664 /newdir/new-file
Kamal Mirdad
Michael Jorgensen
Esteemed Contributor

Re: User mode

Why don't you make the directory writeable by the group in question? Simply do a chmod 77x on the "common directory".

This will allow all members of the group to modify the directory, this will allow them the ability to write to any file in the directory. This would allow them to overwrite the 644 file settings and delete the files.

Vibhor Kumar Agarwal
Esteemed Contributor

Re: User mode

You can make a small script in the .profile

alias for md, touch, and the commands creating files and directories

if pwd = "directory_you_wanted" && user ="you_wanted"
if $1==directory
chmod 774 $1
else
chmod 664 $1
fi
fi
Vibhor Kumar Agarwal