Take the 2-minute tour ×
Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

Dir - test - ls -ld shows

ls -ld test
drwxr-xr-x  2 joe stduser 4096 May 25 16:25 test

inside test dir :

-rw-r--r--  1 admin stduser 0 May 25 16:25 a.txt

How to remove a.txt with out using sudo ..

I just tried

 sudo -u admin rm test/a.txt
rm: cannot remove `test/a.txt': Permission denied

How to resolve this isse ?

share|improve this question

migrated from stackoverflow.com May 25 '11 at 20:16

This question came from our site for professional and enthusiast programmers.

1  
Not a programming question... you're not on the sudo-ers list, and you don't have permission to that file. End of story. –  Anonymous May 25 '11 at 16:35
    
Should be perhaps asked at serverfault.com instead? –  jsalonen May 25 '11 at 16:41

3 Answers 3

up vote 3 down vote accepted

To remove something from a directory, you need write access to the directory. Therefore, in your case, user joe should be able to remove anything from test even if that belongs to admin.

EDIT:

With regular rm, you'll get a warning like: remove write-protected file... ? and you need to answer y. With rm -f you'll get rid of the warning.

But anyway, admin cannot remove that file.

share|improve this answer
rm -f test/a.txt

Forceful is the name of the game

> ls -ld z z/z
drwxr-xr-x 2 joet dev 14 May 25 12:36 z/
-rw-r--r-- 1 root dev  0 May 25 12:36 z/z
> rm -f z/z
> ls -ld z z/z
ls: cannot access z/z: No such file or directory
drwxr-xr-x 2 joet dev 6 May 25 12:36 z/
share|improve this answer

check the owner of the file, and check the group of the file. Now check if the account you have logged into is the owner's account, then you can delete them. Else see if you are within the owner's group and the group has rw permission, then delete them. Else log into root if you have the password and then remove it.

Else boot your system with a live CD/DVD, mount that disk, and delete it.

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.