简体   繁体   中英

Is there an alternate way to apply default permission to files in Unix, other than umask and setfacl?

I have a requirement to apply a default permission to files transferred into a specific folder in Unix. I did a look up on internet and found two ways. However, I can't use them for the reason mentioned:

1. umask

This command can only be used in user login level by mentioning it
in .bashrc / .profile file.  Won't work for me because I want the
permissions to be applied regardless of the logged in user, and only
to a specific folder.
enter code here

2. setfacl

This command can only be used when the drive on which the folder is
located, is mounted with file access listing enabled. This won't for
me because I can't involve Unix system admins in this activity at my
workplace.

Please suggest if there's an alternate (and possibly a simple) way to achieve the solution for my requirement.

I have no knowledge of MIDES, but if your user is allowed to run cron, then a cron entry similar to the following:

          • /usr/bin/chmod /dir_name/*

Eg

          • /usr/bin/chmod 750 /export/xfr/*

would run every minute and change the permissions of all files in your directory to what you want them to be.

It may not be exactly what you are asking for, because it will run on all files in that directory rather than just the ones transferred.

If you need it to only run on certain files within that directory, then you could use something like find to better define the files to act on. Eg

          • /usr/bin/find -user -exec /usr/bin/chmod {} \\;

Eg

          • /usr/bin/find /export/xfr -user narayanf1 -exec /usr/bin/chmod 750 {} \\;

would only change permissions on the files in /export/xfr owned by the user narayanf1.

man find

will give you further options on other options such as creation time, modification time, size, name etc.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM