LinuxQuestions.org
Latest LQ Deal: Linux Power User Bundle
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!

Notices


Reply
  Search this Thread
Old 03-21-2012, 04:51 AM   #1
Raakh5
Member
 
Registered: Mar 2012
Posts: 167

Rep: Reputation: Disabled
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
 
Old 03-21-2012, 05:00 AM   #2
catkin
LQ 5k Club
 
Registered: Dec 2008
Location: Tamil Nadu, India
Distribution: Debian
Posts: 8,576
Blog Entries: 31

Rep: Reputation: 1195Reputation: 1195Reputation: 1195Reputation: 1195Reputation: 1195Reputation: 1195Reputation: 1195Reputation: 1195Reputation: 1195
Is the file system mounted read-only?

What is the line for it in cat /proc/mounts output?
 
Old 03-21-2012, 05:09 AM   #3
Raakh5
Member
 
Registered: Mar 2012
Posts: 167

Original Poster
Rep: Reputation: Disabled
Quote:
Originally Posted by catkin View Post
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

Last edited by Raakh5; 03-21-2012 at 05:11 AM.
 
Old 03-21-2012, 05:30 AM   #4
catkin
LQ 5k Club
 
Registered: Dec 2008
Location: Tamil Nadu, India
Distribution: Debian
Posts: 8,576
Blog Entries: 31

Rep: Reputation: 1195Reputation: 1195Reputation: 1195Reputation: 1195Reputation: 1195Reputation: 1195Reputation: 1195Reputation: 1195Reputation: 1195
They are all mounted rw. Is the directory "test" on one of them?
 
Old 03-21-2012, 05:33 AM   #5
Raakh5
Member
 
Registered: Mar 2012
Posts: 167

Original Poster
Rep: Reputation: Disabled
Thanks again for reply

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

regards
 
Old 03-21-2012, 05:47 AM   #6
catkin
LQ 5k Club
 
Registered: Dec 2008
Location: Tamil Nadu, India
Distribution: Debian
Posts: 8,576
Blog Entries: 31

Rep: Reputation: 1195Reputation: 1195Reputation: 1195Reputation: 1195Reputation: 1195Reputation: 1195Reputation: 1195Reputation: 1195Reputation: 1195
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.
 
Old 03-21-2012, 05:49 AM   #7
Raakh5
Member
 
Registered: Mar 2012
Posts: 167

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

thanks again
 
Old 03-21-2012, 06:01 AM   #8
catkin
LQ 5k Club
 
Registered: Dec 2008
Location: Tamil Nadu, India
Distribution: Debian
Posts: 8,576
Blog Entries: 31

Rep: Reputation: 1195Reputation: 1195Reputation: 1195Reputation: 1195Reputation: 1195Reputation: 1195Reputation: 1195Reputation: 1195Reputation: 1195
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.
 
Old 03-21-2012, 06:23 AM   #9
TxemaM
LQ Newbie
 
Registered: Mar 2012
Distribution: Fedora
Posts: 9

Rep: Reputation: 1
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!
 
1 members found this post helpful.
Old 03-21-2012, 08:00 AM   #10
Raakh5
Member
 
Registered: Mar 2012
Posts: 167

Original Poster
Rep: Reputation: Disabled
[root@myServer cgi-bin]# chattr -i test
[root@myServer cgi-bin]# rm -rf test
rm: cannot remove directory `test': Permission denied
 
Old 03-21-2012, 08:47 AM   #11
grim76
Member
 
Registered: Jun 2007
Distribution: Debian, SLES, Ubuntu
Posts: 308

Rep: Reputation: 50
Is there something using that directory? lsof <path_to_directory>

You may need to stop something that is accessing that file location.
 
Old 03-21-2012, 09:46 AM   #12
catkin
LQ 5k Club
 
Registered: Dec 2008
Location: Tamil Nadu, India
Distribution: Debian
Posts: 8,576
Blog Entries: 31

Rep: Reputation: 1195Reputation: 1195Reputation: 1195Reputation: 1195Reputation: 1195Reputation: 1195Reputation: 1195Reputation: 1195Reputation: 1195
Quote:
Originally Posted by Raakh5 View Post
[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.
 
1 members found this post helpful.
Old 03-21-2012, 09:49 AM   #13
suicidaleggroll
LQ Guru
 
Registered: Nov 2010
Location: Colorado
Distribution: OpenSUSE, CentOS
Posts: 5,481

Rep: Reputation: 2089Reputation: 2089Reputation: 2089Reputation: 2089Reputation: 2089Reputation: 2089Reputation: 2089Reputation: 2089Reputation: 2089Reputation: 2089Reputation: 2089
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.

Last edited by suicidaleggroll; 03-21-2012 at 09:51 AM.
 
1 members found this post helpful.
Old 03-21-2012, 11:56 AM   #14
Raakh5
Member
 
Registered: Mar 2012
Posts: 167

Original Poster
Rep: Reputation: Disabled
[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
 
Old 03-21-2012, 11:57 AM   #15
Raakh5
Member
 
Registered: Mar 2012
Posts: 167

Original Poster
Rep: Reputation: Disabled
[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]#
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
What is the command for deleting a directory? runnerpaul Linux - Newbie 5 03-22-2007 08:20 AM
Deleting a directory esm03 Linux - Newbie 2 06-28-2006 11:15 AM
"WARNING: Circular directory structure" error when deleting directory pistonbrew Linux - Software 5 02-03-2005 06:05 AM
Deleting a directory... closet geek Linux - General 7 07-09-2003 06:25 AM
deleting non-empty directory sadiboyz Linux - Newbie 2 04-21-2003 09:29 PM


All times are GMT -5. The time now is 02:53 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration