1839589 Members
2402 Online
110151 Solutions
New Discussion

deleting a file

 
SOLVED
Go to solution
Shivkumar
Super Advisor

deleting a file

Once i was trying to delete a file owned by me and having permission 644. i got the error message permission denied. finally i deleted as a root.

I was never able to understood why this happened ?

I know some of the unix guru on this forum will shed some light :-))

Thanks,
Shiv
6 REPLIES 6
Devender Khatana
Honored Contributor
Solution

Re: deleting a file

Hi Shiv,

You perhaps do not have right permissions in that directory. If you do not have that you can not delete file.

Let me know if it is not the case.

HTH,
Devender
Impossible itself mentions "I m possible"
Devesh Pant_1
Esteemed Contributor

Re: deleting a file

What is the permissions on the parent directory ?
Check that out and hopefully that is it

DP
john korterman
Honored Contributor

Re: deleting a file

Hi,

as already said: you need write permission on the directory in which the file is located in order to delete it.
The permissions on the file itself, e.g. 644, apply only to reading, writing/changing or executing the file.

regards,
John K.
it would be nice if you always got a second chance
Sandman!
Honored Contributor

Re: deleting a file

Basically the dir in which that file exists should have a "w" in the "other" field of the permissions or a "w" in the "group" field if your ID is part of that group.
Eknath
Trusted Contributor

Re: deleting a file

Hi Shiv,

The process was like this

1. You created a file in a directory for which you have rwx permission.
2. After sometime the directory premission was changed to r_x. Now you cannot modify(write) to the directory...

Following are the steps how it happened
$ ll
total 0
drwx------ 2 abc users 96 Aug 14 04:47 test1
$ > test1/test2
$ chmod 500 test1
$ rm test1/test2
rm: test1/test2 not removed. Permission denied
$ ll
total 0
dr-x------ 2 abc users 96 Aug 14 04:47 test1
$ chmod 700 test1
$ rm test1/test2
$ (file deleted)

Cheers !!!
eknath
Mahesh Kumar Malik
Honored Contributor

Re: deleting a file

Hi Shiv

Probably the parent directory does not have write permission

Regards
Mahesh