How to change the default permission of a file


 
Thread Tools Search this Thread
Top Forums UNIX for Dummies Questions & Answers How to change the default permission of a file
# 1  
Old 08-28-2007
How to change the default permission of a file

I am creating a file using the UTL_FILE command of oracle. This creates a file with the oracle user id. The file does not have permission for being read by any other user id. Is there a way that I can change this default permission. I tried using umask in the .login. Setting the umask to 022 works when i login as the user oracle and create a file. However it does not work for files created using the UTL_FILE command.

Your help is appreciated.

Regards
Samir
# 2  
Old 08-28-2007
Cannot reproduce on 9i.
Do you run the command from the database server (or from a remote client)?

Code:
SQL> create directory test as '/tmp';

Directory created.

SQL> !umask
022

SQL> declare
  2  v_fileid utl_file.file_type; 
  3  begin
  4  v_fileid:=utl_file.fopen('TEST','test_file','a');
  5  utl_file.fclose(v_fileid);
  6  end;
  7  /

PL/SQL procedure successfully completed.

SQL> !ls -l /tmp/test_file
-rw-r--r--   1 oracle   dba            0 Aug 28 21:39 /tmp/test_file

SQL> !rm /tmp/test_file

SQL> exit
Disconnected from Oracle9i Enterprise Edition Release 9.2.0.8.0 - 64bit Production
With the Partitioning, OLAP and Oracle Data Mining options
JServer Release 9.2.0.8.0 - Production
$ umask 000
$ sqlplus '/ as sysdba'

SQL*Plus: Release 9.2.0.8.0 - Production on Tue Aug 28 21:40:59 2007

Copyright (c) 1982, 2002, Oracle Corporation.  All rights reserved.


Connected to:
Oracle9i Enterprise Edition Release 9.2.0.8.0 - 64bit Production
With the Partitioning, OLAP and Oracle Data Mining options
JServer Release 9.2.0.8.0 - Production

SQL> declare
  2  v_fileid utl_file.file_type;
  3  begin
  4  v_fileid:=utl_file.fopen('TEST','test_file','a');
  5  utl_file.fclose(v_fileid);
  6  end;
  7  /

PL/SQL procedure successfully completed.

SQL> !ls -l /tmp/test_file
-rw-rw-rw-   1 oracle   dba            0 Aug 28 21:41 /tmp/test_file

# 3  
Old 08-28-2007
How to change the default permission of a file

Thank you very much for the reply. I am processing this on the server. Would this issue occur if the directory where the file is being created using UTL_FILE command is created using a different id ? Although the directory has full permissions.

I will try what you have sent to me.

Thank you once again.
 
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Need a script to create file permission change restriction

Hello, I am looking for a UNIX shell script which can help me for access restriction. 1) /home/ram, there are number file with .txt extension, which should be only owned "ram" user. like as below ls -lrt *.txt -rwx------ 1 ram dba 11 Jan 4 2015 PASS1.txt -rwx------ 1 ram dba 10 Jan 4... (8 Replies)
Discussion started by: mr.trilok
8 Replies

2. Shell Programming and Scripting

Change file permission of mounted drive Linux

I got a problem with the permission of mounted 2TB drive in my Linux/Mint system. All the files in any folder are with 777, which is not what I want. my fstab line for this disk is: UUID=90803E0C803DF974 /media/grape/Workspace1_ntfs ntfs auto,users,permissions 0 0 and blkid gave me: $> blkid ... (4 Replies)
Discussion started by: yifangt
4 Replies

3. Shell Programming and Scripting

Change permission on a file recursively

Hi, this is the structure of the directory /local/home/app/cases under cases directory, below are the sub directories and each directory has files. /local/home/app/cases/1 /local/home/app/cases/2 /local/home/app/cases/3 /local/home/app/cases/4 File types are .txt .sh and so... (5 Replies)
Discussion started by: lookinginfo
5 Replies

4. UNIX for Dummies Questions & Answers

Change permission to a directory

Hi, How do i change the permission to read/write to a windows directory? (1 Reply)
Discussion started by: lg123
1 Replies

5. UNIX for Dummies Questions & Answers

Change unix permission when I don't own the file

Hi, A file is transferred from a Windows server(say username : user1) to Unix server via ftp. In unix, the permission of the file for a user, say user2 will be "-rw-r-----". Since the user1 is the owner of the file, user2 is not able to change the file permission using chmod. Is there... (5 Replies)
Discussion started by: merin
5 Replies

6. Shell Programming and Scripting

Change the file permission

Guys, I need help. I need to change the .txt file permission after I have reset the file content to 0. The code that reset the file content to 0 is as follows: #!/bin/sh for i in /root/script/*.txt do echo "0" > $i done However, the file is generated by the apache application,... (3 Replies)
Discussion started by: jasperux
3 Replies

7. AIX

Change file permission by anothere user !

Guy's we are in AIX 5.3 We have created two users user1 and user2 and they are under same group Staff Group user1 will create file under /tmp/ and this is the permission of this file -rw-r--r-- 1 user1 staff 1 Jun 13 09:47 file user2 is under same group and when he... (14 Replies)
Discussion started by: ITHelper
14 Replies

8. UNIX for Dummies Questions & Answers

Permission change query

I need to change permission for a directory from drwxrwxrwx to drwxr--s--T What chmod command will work? What will be the number code to represent the required permission? (4 Replies)
Discussion started by: krishmaths
4 Replies

9. Solaris

Permission Change Upon Reboot

I have a Sun 4800 running on Solaris 9 OS. Each time I reboot the server the permissions on /tmp are change from root/sys 1777 to root/root 775. This causes a problem as I have custom programs the need this directory set to root/sys. I have search the sun site and can't find a solution. Anybody... (2 Replies)
Discussion started by: gross
2 Replies

10. UNIX for Advanced & Expert Users

Timestamp of File permission change

Hi!! Experts, Is there any way to find the timestamp when the permission of a file was modified?? I mean no change to file contents.. Just the chnage of permissions. :) (1 Reply)
Discussion started by: jyotipg
1 Replies
Login or Register to Ask a Question