aspose file tools*
The moose likes Linux / UNIX and the fly likes rm: cannot remove :  Permission denied Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Engineering » Linux / UNIX
Bookmark "rm: cannot remove :  Permission denied" Watch "rm: cannot remove :  Permission denied" New topic
Author

rm: cannot remove : Permission denied

jaya kemmannu
Ranch Hand

Joined: Sep 23, 2011
Posts: 85

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
Marshal

Joined: Mar 22, 2005
Posts: 42648
    
  65
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.


Ping & DNS - my free Android networking tools app
jaya kemmannu
Ranch Hand

Joined: Sep 23, 2011
Posts: 85

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
Sheriff

Joined: Sep 28, 2004
Posts: 19004
    
  40

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


Books: Java Threads, 3rd Edition, Jini in a Nutshell, and Java Gems (contributor)
jaya kemmannu
Ranch Hand

Joined: Sep 23, 2011
Posts: 85
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
Sheriff

Joined: Sep 28, 2004
Posts: 19004
    
  40

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

Joined: Sep 23, 2011
Posts: 85

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

Joined: Feb 06, 2008
Posts: 466
    
    1

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.


Vinod Tiwari | Twitter | Shikshanirman | Guftgu
jaya kemmannu
Ranch Hand

Joined: Sep 23, 2011
Posts: 85

Hi,

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

Regards,
Jay

 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: rm: cannot remove : Permission denied