There's a really annoying situation. I own a directory but someone else created a subdirectory in it that I'd like to delete but I cannot because it's not empty. I thought, that owning the directory would give me the right to do that (I don't have root privileges). What else can I do?

$ ls -la
drwxr-xr-x   4 myself   eng         4096  Jul 21 15:17 .
drwxrwxr-t 788 root     eng         69632 Jul 20 13:20 ..
drwxrwxr-x   4 someguy  eng         8192  Jul 21 15:13 stuff
$ ls -l stuff
-rw-r-----   4 someguy  eng         8192  Jul 21 15:13 somefile
drwxr-----   4 someguy  eng         8192  Jul 21 15:13 morestuff
link|improve this question
This is a question more suited to serverfault.com. – zombat Jul 21 '09 at 19:34
feedback

migrated from stackoverflow.com Jul 22 '09 at 2:51

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

3 Answers

Based on the file permissions, you can't.

link|improve this answer
Yes, but why? Suppose I go low-level and try to modify the directory file directly (I have write permission, after all). Who will prevent me from doing that? The OS? But how? Even trickier: How does the OS know that a directory is not empty? If I don't have read permission on the subdirectory, yet I cannot delete it, does that mean the OS just revealed information I had no permission to access in the first place. (Just musing, don't mind me.) – Lajos Nagy Jul 21 '09 at 21:01
@Lajos: Modern OSes no longer allow you do modify the directory directly, even with write permission. – ephemient Jul 21 '09 at 21:13
feedback
mv stuff ..
link|improve this answer
wont work. I got error while trying to move one directory to /tmp. I could move my own files to /tmp. – Saurabh Barjatiya Jul 22 '09 at 7:53
Read man 2 rename: "EACCES Write permission is denied for the directory containing oldpath or newpath, or, search permission is denied for one of the directories in the path prefix of oldpath or newpath, or oldpath is a directory and does not allow write permission (needed to update the .. entry)." This clearly falls into the last situation. – ephemient Jul 22 '09 at 16:41
Actually the OP does have write permission to oldpath (stuff), assuming he is in group eng. (I assumed that since his directory was also owned by that group, and .. is not setgid.) – mark4o Jul 22 '09 at 17:35
1  
@Saurabh The directory has to be on the same filesystem, and you need write permission to the directory you are moving, as in the question. – mark4o Jul 22 '09 at 17:40
Ah, right. If you're doing a cross-filesystem mv, rename doesn't work and mv has to create new + remove old, which OP seems to lack permissions for. – ephemient Jul 22 '09 at 17:50
feedback

Do you have any sudo rights? If not, looks like you'll have to talk to the admin.

link|improve this answer
feedback

Your Answer

 
or
required, but never shown

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