LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Newbie (https://www.linuxquestions.org/questions/linux-newbie-8/)
-   -   Not deleting directory (https://www.linuxquestions.org/questions/linux-newbie-8/not-deleting-directory-935638/)

Raakh5 03-21-2012 04:51 AM

Not deleting directory
 
Hello,

[root@myServer cgi-bin]# rm -rf test
rm: cannot remove directory `test': Permission denied
[root@myServer cgi-bin]# ls
test
[root@myServer cgi-bin]# ls -la
total 12
drwxr-x--- 3 10040 psaserv 4096 May 2 2010 .
drwxr-xr-x 3 root root 4096 Mar 21 01:16 ..
drwxr-xr-x 2 10040 psacln 4096 Mar 21 01:11 test
[root@myServer cgi-bin]#

Regards

catkin 03-21-2012 05:00 AM

Is the file system mounted read-only?

What is the line for it in cat /proc/mounts output?

Raakh5 03-21-2012 05:09 AM

Quote:

Originally Posted by catkin (Post 4632364)
Is the file system mounted read-only?

What is the line for it in cat /proc/mounts output?

rootfs / rootfs rw 0 0
/dev/root / ext3 rw,data=ordered 0 0
/dev /dev tmpfs rw 0 0
/proc /proc proc rw 0 0
/sys /sys sysfs rw 0 0
/proc/bus/usb /proc/bus/usb usbfs rw 0 0
devpts /dev/pts devpts rw 0 0
/dev/sda1 /boot ext3 rw,data=ordered 0 0
tmpfs /dev/shm tmpfs rw 0 0
none /proc/sys/fs/binfmt_misc binfmt_misc rw 0 0
sunrpc /var/lib/nfs/rpc_pipefs rpc_pipefs rw 0 0
/etc/auto.misc /misc autofs rw,fd=6,pgrp=2835,timeout=300,minproto=5,maxproto=5,indirect 0 0
-hosts /net autofs rw,fd=12,pgrp=2835,timeout=300,minproto=5,maxproto=5,indirect 0 0
/proc /var/named/run-root/proc proc rw 0 0
/dev/root /var/named/run-root/var/run/dbus ext3 rw,data=ordered 0 0
tmpfs /usr/local/psa/handlers/before-local tmpfs rw 0 0
tmpfs /usr/local/psa/handlers/before-queue tmpfs rw 0 0
tmpfs /usr/local/psa/handlers/before-remote tmpfs rw 0 0
tmpfs /usr/local/psa/handlers/info tmpfs rw 0 0
tmpfs /usr/local/psa/handlers/spool tmpfs rw 0 0


regards

catkin 03-21-2012 05:30 AM

They are all mounted rw. Is the directory "test" on one of them?

Raakh5 03-21-2012 05:33 AM

Thanks again for reply

Its in each and every /var/www/vhosts/domainName/cgi-bin/test

regards

catkin 03-21-2012 05:47 AM

Are the /var/www/vhosts/<domain name>/cgi-bin/test files on the / file system as appears from /proc/mounts? There's still the possibility they are on a network file system.

Are there any extra access controls? /bin/ls -l test would show a . or a + after the permissions if there were. Please use /bin/ls not ls to ensure no alias is in use.

Raakh5 03-21-2012 05:49 AM

[root@myServer cgi-bin]# /bin/ls -l
total 4
drwxr-xr-x 2 medical5 psacln 4096 Dec 18 04:15 test

thanks again

catkin 03-21-2012 06:01 AM

Ah ...

Can you change the holding directory's owner to root?

chown root .

If that works, can you then delete it? (I'm not expecting it to work because the -f option of rm should have dealt with that case).

Try using /bin/rm -- again to avoid possible alias complications.

TxemaM 03-21-2012 06:23 AM

Hello,

Try listing the directory attributes:

$ lsattr test

Is immutable attribute set? (if it is, you will see an "i" among the listed attibutes, like this ----i--------e- .

To unset it, like root type:

# chattr -i test

And now (as user) you can try to delete it again. If it fails, verify that any file inside it do not have immutable attribute set.

Good luck!

Raakh5 03-21-2012 08:00 AM

[root@myServer cgi-bin]# chattr -i test
[root@myServer cgi-bin]# rm -rf test
rm: cannot remove directory `test': Permission denied

grim76 03-21-2012 08:47 AM

Is there something using that directory? lsof <path_to_directory>

You may need to stop something that is accessing that file location.

catkin 03-21-2012 09:46 AM

Quote:

Originally Posted by Raakh5 (Post 4632478)
[root@myServer cgi-bin]# chattr -i test
[root@myServer cgi-bin]# rm -rf test
rm: cannot remove directory `test': Permission denied

chattr -i test would only remove immutable from the directory.

chattr -R -i test would remove it from the directory and anything under it.

lsattr -R test to see if there are any attributes set on the directory and anything under it.

suicidaleggroll 03-21-2012 09:49 AM

In your first post, the owner is UID 10040
In your fourth post, the owner is medical5

What has changed between the first and fourth posts? Usually when the owner is just a UID, not an actual username, it means you're working on a network filesystem (NFS, etc), which means root won't have the same permissions as on the local filesystem.

Raakh5 03-21-2012 11:56 AM

[root@myServer cgi-bin]# chown root test
[root@myServer cgi-bin]# /bin/rm -rf test
/bin/rm: cannot remove directory `test': Permission denied
[root@myServer cgi-bin]# /bin/rm -f test
/bin/rm: cannot remove `test': Permission denied
[root@myServer cgi-bin]# /bin/rm test
/bin/rm: cannot remove `test': Permission denied
[root@myServer cgi-bin]#

---------- Post added 03-21-12 at 11:56 AM ----------

[root@myServer cgi-bin]# lsattr test
[root@myServer cgi-bin]# ls -l
total 4
drwxr-xr-x 2 root psacln 4096 Mar 21 01:11 test
[root@myServer cgi-bin]# chattr -i test
[root@myServer cgi-bin]# ls
test
[root@myServer cgi-bin]# rm -rf test
rm: cannot remove directory `test': Permission denied
[root@myServer cgi-bin]# cd test
[root@myServer test]# ls

Raakh5 03-21-2012 11:57 AM

[root@myServer cgi-bin]# lsof test
[root@myServer cgi-bin]#

---------- Post added 03-21-12 at 11:58 AM ----------

[root@myServer cgi-bin]# chattr -i test
[root@myServer cgi-bin]# chattr -R -i test
[root@myServer cgi-bin]# lsattr -R test
[root@myServer cgi-bin]# ls
test
[root@myServer cgi-bin]# rm -rf test
rm: cannot remove directory `test': Permission denied
[root@myServer cgi-bin]#


All times are GMT -5. The time now is 07:47 AM.