Visit Our UNIX and Linux User Community


Change permissions for files


 
Thread Tools Search this Thread
Operating Systems Solaris Change permissions for files
# 1  
Old 02-04-2014
Change permissions for files

Hi!

I have a dir in a server, that receives files with the wrong permissions, so I decide to put on a cron entry that changes its permitions, but because of the time gap, not all of them get changed.
What I did was the following:

Code:
0,3,5,7,9,11,13,15,17,21,23,25,27,29,31,33,35,37,39,41,43,45,47,49,51,53,55,57,59  * * * * find /dir/sub_dir -type f ! -perm a+rw -exec chmod a+rw  {} +

Can you help me to provide me with a better idea?
# 2  
Old 02-04-2014
If the user account is only for delivering files and it fits to your environment, you could set a umask of 111 for this user to have all files with the same permissions that are created.

If you tend to use the cronjob, maybe just use another * instead of all these comma separated minutes. Have the output redirected to /dev/null to not spam your logs, ie. something like this:
Code:
* * * * find /dir/sub_dir -type f ! -perm a+rw -exec chmod a+rw  {} \; > /dev/null 2>&1

It could be you will need absolute paths to find and chmod etc. or maybe just put it into a little script (I personally prefer that) and call this script via cron.

Depending on how the files are deliviered, maybe you can set a umask with the file transfer tool you are using.
# 3  
Old 02-04-2014
Change permissions for files

Hi
The files are sent by a mediation device using
Code:
ftp

---------- Post updated at 02:39 PM ---------- Previous update was at 02:34 PM ----------

Hi

I had an error when trying to change to your suggestion:

Code:
* * * * find  /dir/sub_dir -type f ! -perm a+rw -exec chmod a+rw {} \; > /dev/null 2>&1
crontab: error on previous line; unexpected character found in line.
crontab: errors detected in input, no crontab file generated.

# 4  
Old 02-04-2014
As said, better put it into a script and have the paths to find and as absolute paths.

You can try to add the ftp command
Code:
site umask 111

when sending the file to have it the correct permissions. You can also have the ftpd a default umask in /etc/inetd.conf, but that will be for all transfers then.

Also you might want to think using scp/sftp if possible, since ftp is not encrypted.

Last edited by zaxxon; 02-04-2014 at 08:58 AM..
# 5  
Old 02-04-2014
Change permissions for files

the
Code:
umask

command is to run on the server that is sending the files?
# 6  
Old 02-04-2014
No, on the receiving side in the users environment/profile but this will be default for all the user does.

Forget about umask, forget about the cronjob.

Try following:
Add in the ftp-call on the sending side adding
Code:
site umask 111

before you put or mput the files.

That should do the trick.
This User Gave Thanks to zaxxon For This Post:
# 7  
Old 02-06-2014
Change permissions for files

The owner or sender says that cannot change permission using
Code:
umask

because its not recommended to change the permission of a raw CDR file

Previous Thread | Next Thread
Test Your Knowledge in Computers #877
Difficulty: Medium
A real-time operating system (RTOS) is an operating system (OS) intended to serve real-time applications that process data as it comes in, typically without buffer delays.
True or False?

10 More Discussions You Might Find Interesting

1. UNIX for Beginners Questions & Answers

Command to change add permissions for a new user to all files in all subfolders and folders

Hi there! I'm new to Unix and haven't done command line stuff since MS-Dos and Turbo Pascal (hah!), I would love some help figuring out this basic command (what I assume is basic). I'd like to add a User to the permissions of all files in a folder and all files in all subfolders, as well... (9 Replies)
Discussion started by: Janjbrt
9 Replies

2. Shell Programming and Scripting

Script to change Permissions on files and directories

Hey, It's me again. Have a problem, that's not really a problem. I have the below script, that goes to the directory I want it to go to. lists out the directories available, lets you choose the directory you want, then it changes the permissions on said directory. using chmod -R and chown -R. ... (2 Replies)
Discussion started by: gkelly1117
2 Replies

3. Shell Programming and Scripting

Help on script to change permissions

Hi All I have the following script that is supposed to change permissions of incoming files to a directory, but it does not seem to do what I want, please can you help: mkdir -p /tmp/tmpdir find /moneta_polled01/sgsn/ -exec ls -l {} \; |grep -v rwxrwxrwx |awk '{print $9}' >... (4 Replies)
Discussion started by: fretagi
4 Replies

4. UNIX for Dummies Questions & Answers

Change permissions

Hi everyboy, I've installed a Virtualbox on my computer, inside the VB i'm running RedHat. So my problems it's that i need to run the scripts runasroot.sh to install the guest addiont, i'm doing this by console. I wrote chmod 775 ./runasroot.sh but doesn't works. I'm login as root user. Any... (8 Replies)
Discussion started by: Newer
8 Replies

5. UNIX for Dummies Questions & Answers

To change permissions in mv or cp

Is there any option with mv or cp command so that a file permissions and name of the file can be changed in single mv or cp command. I searched man mv but doesn't found any option like that. (3 Replies)
Discussion started by: Devesh5683
3 Replies

6. Shell Programming and Scripting

ksh; Change file permissions, update file, change permissions back?

Hi, I am creating a ksh script to search for a string of text inside files within a directory tree. Some of these file are going to be read/execute only. I know to use chmod to change the permissions of the file, but I want to preserve the original permissions after writing to the file. How can I... (3 Replies)
Discussion started by: right_coaster
3 Replies

7. UNIX for Dummies Questions & Answers

Need to change permissions

Hi everyone, There are couple of users of which i need to give 2 of the users admin rights so that they are able to run the administration commands like "zoneadm" and locale. When logged in as root i am obviously able to do that.please suggest any way by which the other 2 user's permissions can... (3 Replies)
Discussion started by: sankasu
3 Replies

8. Shell Programming and Scripting

script to change the access permissions of the files

Hi, I want to change the access permissions of the files whose extension is same.For example *.c but these are inside a directory and inside that other directory is there and it contains the .c files..for example-- So my aim is to search the files under src and change the access permissions... (3 Replies)
Discussion started by: smartgupta
3 Replies

9. UNIX for Dummies Questions & Answers

how to change permissions only to files, not directories....?

Hi, I am really new to unix, any help is much appreciated. I need to change permissions of all files under several subdirectories to 700 but keep directories readable (755). Why ? Because I need a FTP user to only list his files and can't read them. But to browse to subfolder, the directories... (3 Replies)
Discussion started by: narrok
3 Replies

10. UNIX for Dummies Questions & Answers

How to change default permissions on new files

Hello, I would like to know if there was any way I can change the default permissions for new files being generated within a certain directory. Would I need to have the same permissions set at the directory level as for the files being generated in it. Regards, Rdgblues (1 Reply)
Discussion started by: rdgblues
1 Replies

Featured Tech Videos