How to create all files generated in a directory with 644 permissions?


 
Thread Tools Search this Thread
Operating Systems AIX How to create all files generated in a directory with 644 permissions?
# 1  
Old 10-16-2014
Error How to create all files generated in a directory with 644 permissions?

Hi,

We are using AIX machines. How to create all files generated in a directory with 644 permissions automatically.


Regards,
Suresh
# 2  
Old 10-16-2014
Quote:
Originally Posted by suresh3566
Hi,

We are using AIX machines. How to create all files generated in a directory with 644 permissions automatically.


Regards,
Suresh
Code:
mkdir -m 644 dirname

---------- Post updated at 07:30 PM ---------- Previous update was at 07:26 PM ----------

Code:
root@nio:/tmp# mkdir -m 644 testdir

root@nio:/tmp# touch testdir/file1

root@nio:/tmp# stat -c "%a %n" testdir/
644 testdir/

root@nio:/tmp# stat -c "%a %n" testdir/file1 
644 testdir/file1

# 3  
Old 10-16-2014
I think I'd like to correct this. As far as I'm aware, permissions when creating files is set by the inverse of the umask value. The command above will create a directory with tw-r--r-- permissions (meaning you cannot cd into it) but that's all.

To create files with permissions 644, do the following:-
Code:
umask=022
touch /tmp/my_file
ls -l /tmp/myfile

For me, umask=066, so default permissions are rw-------



Robin
These 2 Users Gave Thanks to rbatte1 For This Post:
# 4  
Old 10-16-2014
Yes Robin..

I am unable to do cd directory. I have already a directory with below permissions. Now, whatever the files generating in this directory, should generate with 644 permissions. How to get this?

drwxrwxr-x dump

Regards,
Suresh
# 5  
Old 10-16-2014
rbatte1: thanks for sharing knowledge Smilie. I wish I would have created and tested as a normal user Smilie
# 6  
Old 10-16-2014
You use umask command and its per user or set as default for all in AIX I suppose in /etc/environment ...
What you want is
Code:
 umask 022

See Robin's explanation above
# 7  
Old 10-16-2014
Depending on the shell and the user you run it under, changing the umask to 022 might be sufficient.
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. UNIX for Beginners Questions & Answers

How to create a summary file of all files in a directory sorted in reverse alphabetical order.?

I have an interactive script which works terrific at processing a folder of unsorted files into new directories. I am wondering how I could modify my script so that( upon execution) it provides an additional labelled summary file on my desktop that lists all of the files in each directory that... (4 Replies)
Discussion started by: Braveheart
4 Replies

2. Shell Programming and Scripting

How Create new directory and move files to that directory.?

Hi All, We have main directory called "head" under this we have several sub directories and under these directories we have sub directories. My requirement is I have to find the SQL files which are having the string "procedure" under "head" directory and sub directories as well. And create... (14 Replies)
Discussion started by: ROCK_PLSQL
14 Replies

3. Shell Programming and Scripting

List files with date, create directory, move to the created directory

Hi all, i have a folder, with tons of files containing as following, on /my/folder/jobs/ some_name_2016-01-17-22-38-58_some name_0_0.zip.done some_name_2016-01-17-22-40-30_some name_0_0.zip.done some_name_2016-01-17-22-48-50_some name_0_0.zip.done and these can be lots of similar files,... (6 Replies)
Discussion started by: charli1
6 Replies

4. Shell Programming and Scripting

Create dynamical from files in directory

Hello I putting together a menu script for some processing operations and I want to do the following, was googling for some time, but can figure the following out. Im in a folder lets say /input_files I want to list the files something like the following, each file is assigned a number,... (3 Replies)
Discussion started by: kl1ngac1k
3 Replies

5. UNIX for Dummies Questions & Answers

Need help how to create a file (xml) list all files from directory

I have more than 10K songs in two directories on a hard drive. I would like to create a file list all of files name then change to .xml extension to upload to iPhone so I have a Karaoke list on my iPhone. I need your help to create a file by using command in Linux. Files names: 0001 More... (4 Replies)
Discussion started by: ggcc
4 Replies

6. Shell Programming and Scripting

Checking directory permissions on UNIX directory

Hi, How do i check if I have read/write/execute rights on a UNIX directory? What I'm doing is checking read access on the files but i also want to check if user has rights on the direcory in whcih these files are present. if then...... And I check if the directory exists by using... (6 Replies)
Discussion started by: chetancrsp18
6 Replies

7. Shell Programming and Scripting

How to create multiple list of files in a directory ?

Hi, i have say 100 files in a directory. file1.log file2.log file3.log file4.log file5.log file6.log ... ... ... file99.log file100.log ========= I need to create another file which contains the list of al these log files. each file should contain only 10 log file names. it shud... (4 Replies)
Discussion started by: robinbannis
4 Replies

8. UNIX for Dummies Questions & Answers

SCO 5.0.7 Cron creates files with 600, need 644

Hi, I've searched and read, and searched and read some more; but I'm still not connecting the dots or understanding what I need to change. I have a script that creates a file. If I run it as root, the file gets created with 644 permissions like I want. That seems to make sense (at least I... (2 Replies)
Discussion started by: 65bit
2 Replies

9. HP-UX

To give the "unzip" permissions & "create" file permissions

Hi, I am a Unix Admin. I have to give the permissions to a user for creating new file in a directory in HP-Ux 11.11 system since he cannot able to create a new file in the directory. Thanks in advance. Mike (3 Replies)
Discussion started by: Mike1234
3 Replies

10. UNIX for Dummies Questions & Answers

new directory - how to force files created in it to inherit grp,own and permissions

Hi, I'm new to unix -solaris. I've just upgraded a third party software product and am testing it to see if new files created in a test database directory were being created properly and they aren't. They're owned by the user that created the file, instead of poppa and the group of their files... (2 Replies)
Discussion started by: avisb
2 Replies
Login or Register to Ask a Question