Granny's Programming Pearls
"inside of every large program is a small program struggling to get out"
JavaRanch.com/granny.jsp
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

rm: cannot remove : Permission denied

 
jaya kemmannu
Ranch Hand
Posts: 92
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

Hi,

I am trying to delete files inside directory using script. But i end up with error " rm: cannot remove `/software//11-09-2011/summary-1.txt': Permission denied Error. How can i rectify this error.

Below is file permission for my script :

-rwxrwxrwx 1 oracle oinstall 334 Dec 1 17:00 purgeMediationFiles.sh

The directory which contain files has below permission :

drwxr-xr-x 3 oracle oinstall 12288 Aug 13 2011 12-08-2011

And all the file inside this directory is with permission :

-rw-r--r-- 1 oracle oinstall 63932 Aug 13 2011 summary-1.txt

Regards,
Jay
 
Ulf Dittmer
Rancher
Posts: 42968
73
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Which user account are you using to delete those files? It must be "oracle", because nobody else has write (i.e., delete) permissions to that file.
 
jaya kemmannu
Ranch Hand
Posts: 92
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

Hi,


I am logged in as other than oracle and root user like "jay123". Since owner of the script " purgeMediationFiles.sh " is oracle , if i try to run the script as different user(jay123) i thought it will delete the text files. Is my understanding wrong?

Regards,
Jaya
 
Henry Wong
author
Marshal
Pie
Posts: 21496
84
C++ Chrome Eclipse IDE Firefox Browser Java jQuery Linux VI Editor Windows
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
jaya kemmannu wrote:
I am logged in as other than oracle and root user like "jay123". Since owner of the script " purgeMediationFiles.sh " is oracle , if i try to run the script as different user(jay123) i thought it will delete the text files. Is my understanding wrong?


No. Having permissions to run a script doesn't mean you get the authority of the owner of the script. For that option, you need to turn on the setuid flag on the script. And to turn on that flag, you will need write permission on the directory where the script resides.

Henry
 
jaya kemmannu
Ranch Hand
Posts: 92
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks Henry .. Any idea on how to turn on setuid on my script. to do so do we need oracle user login ?
 
Henry Wong
author
Marshal
Pie
Posts: 21496
84
C++ Chrome Eclipse IDE Firefox Browser Java jQuery Linux VI Editor Windows
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
jaya kemmannu wrote:Thanks Henry .. Any idea on how to turn on setuid on my script. to do so do we need oracle user login ?


As mentioned, you need write permission on the directory -- and having the oracle login is probably the easiest way to obtain it.

Henry
 
jaya kemmannu
Ranch Hand
Posts: 92
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

I was able to delete files which is having same file permission structures that are located in different path with different login.
 
Vinod Tiwari
Ranch Hand
Posts: 466
1
IntelliJ IDE Java Oracle
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
This is a permission issue, your user is not having privileges to delete the file. Check for the group which has delete access to the files and have your user added to it.
 
jaya kemmannu
Ranch Hand
Posts: 92
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

Hi,

How to Check for the group which has delete access to the files and add them to group ?

Regards,
Jay

 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic