LinuxQuestions.org
Latest LQ Deal: Complete CCNA, CCNP & Red Hat Certification Training 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-23-2012, 04:13 AM   #31
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

Sorry -- should have been chown root .
 
Old 03-23-2012, 04:22 AM   #32
John VV
LQ Muse
 
Registered: Aug 2005
Location: A2 area Mi.
Posts: 17,229

Rep: Reputation: 2522Reputation: 2522Reputation: 2522Reputation: 2522Reputation: 2522Reputation: 2522Reputation: 2522Reputation: 2522Reputation: 2522Reputation: 2522Reputation: 2522
well the chown line is wrong

from the cgi-bin folder for the folder "test "
Code:
su -
chown -R root:root test 
--- or ----
chown -R root test
please read the man page on chown

however "rm" normally dose not like to remove folders
great for a file

try the tool for removing folders "rmdir"

but in a cgi-bin folder on a server rm might not be the best tool for removing a file
"shred" might be better ?? maybe
from the cgi-bin/test
Code:
shred - n 1 -zuv *
see the man page for shred and the warnings on file systems
 
Old 03-23-2012, 05:30 AM   #33
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 John VV View Post
however "rm" normally dose not like to remove folders
Raakh5 has been using rm -fr test so that's not an issue.
 
Old 03-23-2012, 05:50 AM   #34
Raakh5
Member
 
Registered: Mar 2012
Posts: 169

Original Poster
Rep: Reputation: Disabled
Code:
[root@myServer cgi-bin]# chown root .
chown: changing ownership of `.': Operation not permitted
[root@myServer cgi-bin]# /bin/ls -l
total 4
drwxrwxrwx 2 root root 4096 Mar 22 23:32 test
[root@myServer cgi-bin]# rmdir test
rmdir: test: Permission denied
[root@myServer cgi-bin]# shred - n 1 -zuv *
shred: -: invalid file type
shred: n: failed to open for writing: No such file or directory
shred: 1: failed to open for writing: No such file or directory
shred: test: failed to open for writing: Is a directory
[root@myServer cgi-bin]#
 
Old 03-23-2012, 07:05 AM   #35
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
What's the output of cat /etc/fstab ?
 
Old 03-23-2012, 07:11 AM   #36
Raakh5
Member
 
Registered: Mar 2012
Posts: 169

Original Poster
Rep: Reputation: Disabled
Quote:
Originally Posted by catkin View Post
What's the output of cat /etc/fstab ?
Code:
LABEL=/1                /                       ext3    defaults        1 1
LABEL=/boot             /boot                   ext3    defaults        1 2
tmpfs                   /dev/shm                tmpfs   defaults        0 0
devpts                  /dev/pts                devpts  gid=5,mode=620  0 0
sysfs                   /sys                    sysfs   defaults        0 0
proc                    /proc                   proc    defaults        0 0
LABEL=SWAP-sda2         swap                    swap    defaults        0 0
 
Old 03-23-2012, 02:48 PM   #37
Sydney
Member
 
Registered: Mar 2012
Distribution: Scientific Linux
Posts: 147

Rep: Reputation: 36
chown -R root /var/www/vhosts/myDomain/cgi-bin
ls -l /var/www/vhosts/myDomain/*
ls -l /var/www/vhosts/myDomain/cgi-bin/*
ls -l /var/www/vhosts/myDomain/cgi-bin/test/*
unlink /var/www/vhosts/myDomain/cgi-bin/test/*
rm -rf /var/www/vhosts/myDomain/cgi-bin/test/*
rm -rf /var/www/vhosts/myDomain/cgi-bin/test
 
Old 03-23-2012, 02:59 PM   #38
Raakh5
Member
 
Registered: Mar 2012
Posts: 169

Original Poster
Rep: Reputation: Disabled
Code:
[root@myServer myDomain]# chown -R root /var/www/vhosts/myDomain/cgi-bin
chown: changing ownership of `/var/www/vhosts/myDomain/cgi-bin': Operation not permitted

[root@myServer myDomain]# ls -l /var/www/vhosts/myDomain/*
total 4
drwxrwxrwx 2 root root 4096 Mar 22 23:32 test

[root@myServer myDomain]# ls -l /var/www/vhosts/myDomain/cgi-bin/*total 0
-rw-r--r-- 1 root root 0 Mar 22 23:32 testfile

[root@myServer myDomain]# ls -l /var/www/vhosts/myDomain/cgi-bin/test/*
-rw-r--r-- 1 root root 0 Mar 22 23:32 /var/www/vhosts/myDomain/cgi-bin/test/testfile

[root@myServer myDomain]# unlink /var/www/vhosts/myDomain/cgi-bin/test/*

[root@myServer myDomain]# rm -rf /var/www/vhosts/myDomain/cgi-bin/test/*

[root@myServer myDomain]# rm -rf /var/www/vhosts/myDomain/cgi-bin/test
rm: cannot remove directory `/var/www/vhosts/myDomain/cgi-bin/test': Permission denied

[root@myServer myDomain]#
Thanks again
 
Old 03-23-2012, 03:06 PM   #39
Sydney
Member
 
Registered: Mar 2012
Distribution: Scientific Linux
Posts: 147

Rep: Reputation: 36
It looks to me like you moved cgi-bin from another box here. The ownership was messed up because there is no user associated with uid 10041. My best guess would be to useradd newuser then go into /etc/passwd and find that user. Change their uid to 10041 then passwd newuser su newuser cd to cgi-bin then rm -rf test.
 
Old 03-23-2012, 03:22 PM   #40
John VV
LQ Muse
 
Registered: Aug 2005
Location: A2 area Mi.
Posts: 17,229

Rep: Reputation: 2522Reputation: 2522Reputation: 2522Reputation: 2522Reputation: 2522Reputation: 2522Reputation: 2522Reputation: 2522Reputation: 2522Reputation: 2522Reputation: 2522
Quote:
chown root .
just so you know
there is NO "." at the end of that command
the "." would be the FILE/FOLDER name
so do not put an . at the end of that command

please read the man page !
 
Old 03-23-2012, 10:50 PM   #41
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 John VV View Post
just so you know
there is NO "." at the end of that command
the "." would be the FILE/FOLDER name
so do not put an . at the end of that command

please read the man page !
Thanks John but that was my intention -- to change test's parent directory, cgi-bin -- and the technique works:
Code:
c@CW8:/tmp$ mkdir dir
root@CW8:~# cd /tmp/dir
root@CW8:/tmp/dir# chown root .
root@CW8:/tmp/dir# ll -a
total 8.0K
drwxr-xr-x 2 root users    1 Mar 24 08:17 .
drwxrwxrwt 8 root root  4.0K Mar 24 08:17 ..
 
Old 03-23-2012, 11:06 PM   #42
Tinkster
Moderator
 
Registered: Apr 2002
Location: in a fallen world
Distribution: slackware by choice, others too :} ... android.
Posts: 23,067
Blog Entries: 11

Rep: Reputation: 910Reputation: 910Reputation: 910Reputation: 910Reputation: 910Reputation: 910Reputation: 910Reputation: 910
Have you tried stopping apache before you tried to remove the directory? Just a thought.



Cheers,
Tink
 
Old 03-24-2012, 10:06 AM   #43
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
What is the output of strace rm -fr test ?
 
Old 03-25-2012, 06:41 AM   #44
Raakh5
Member
 
Registered: Mar 2012
Posts: 169

Original Poster
Rep: Reputation: Disabled
Code:
execve("//bin/rm", ["rm", "-fr", "test"], [/* 27 vars */]) = 0
brk(0)                                  = 0x9d1c000
access("/etc/ld.so.preload", R_OK)      = -1 ENOENT (No such file or directory)
open("/etc/ld.so.cache", O_RDONLY)      = 3
fstat64(3, {st_mode=S_IFREG|0644, st_size=33549, ...}) = 0
mmap2(NULL, 33549, PROT_READ, MAP_PRIVATE, 3, 0) = 0xb7f43000
close(3)                                = 0
open("/lib/libc.so.6", O_RDONLY)        = 3
read(3, "\177ELF\1\1\1\0\0\0\0\0\0\0\0\0\3\0\3\0\1\0\0\0\320\357\235\0004\0\0\0"..., 512) = 512
fstat64(3, {st_mode=S_IFREG|0755, st_size=1606808, ...}) = 0
mmap2(NULL, 4096, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0) = 0xb7f42000
mmap2(0x9c9000, 1324452, PROT_READ|PROT_EXEC, MAP_PRIVATE|MAP_DENYWRITE, 3, 0) = 0x9c9000
mmap2(0xb07000, 12288, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_FIXED|MAP_DENYWRITE, 3, 0x13e) = 0xb07000
mmap2(0xb0a000, 9636, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_FIXED|MAP_ANONYMOUS, -1, 0) = 0xb0a000
close(3)                                = 0
mmap2(NULL, 4096, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0) = 0xb7f41000
set_thread_area({entry_number:-1 -> 6, base_addr:0xb7f416c0, limit:1048575, seg_32bit:1, contents:0, read_exec_only:0, limit_in_pages:1, seg_not_present:0, useable:1}) = 0
mprotect(0xb07000, 8192, PROT_READ)     = 0
mprotect(0x9c5000, 4096, PROT_READ)     = 0
munmap(0xb7f43000, 33549)               = 0
brk(0)                                  = 0x9d1c000
brk(0x9d3d000)                          = 0x9d3d000
open("/usr/lib/locale/locale-archive", O_RDONLY|O_LARGEFILE) = 3
fstat64(3, {st_mode=S_IFREG|0644, st_size=56471232, ...}) = 0
mmap2(NULL, 2097152, PROT_READ, MAP_PRIVATE, 3, 0) = 0xb7d41000
close(3)                                = 0
ioctl(0, SNDCTL_TMR_TIMEBASE or TCGETS, {B38400 opost isig icanon echo ...}) = 0
unlink("test")                          = -1 EACCES (Permission denied)
open(".", O_RDONLY|O_LARGEFILE)         = 3
lstat64("test", {st_mode=S_IFDIR|0777, st_size=4096, ...}) = 0
chdir("test")                           = 0
lstat64(".", {st_mode=S_IFDIR|0777, st_size=4096, ...}) = 0
open(".", O_RDONLY|O_NONBLOCK|O_LARGEFILE|O_DIRECTORY) = 4
fstat64(4, {st_mode=S_IFDIR|0777, st_size=4096, ...}) = 0
fcntl64(4, F_SETFD, FD_CLOEXEC)         = 0
getdents64(4, /* 2 entries */, 4096)    = 48
getdents64(4, /* 0 entries */, 4096)    = 0
close(4)                                = 0
fchdir(3)                               = 0
rmdir("test")                           = -1 EACCES (Permission denied)
open("/usr/share/locale/locale.alias", O_RDONLY) = 4
fstat64(4, {st_mode=S_IFREG|0644, st_size=2528, ...}) = 0
mmap2(NULL, 4096, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0) = 0xb7f4b000
read(4, "# Locale name alias data base.\n#"..., 4096) = 2528
read(4, "", 4096)                       = 0
close(4)                                = 0
munmap(0xb7f4b000, 4096)                = 0
open("/usr/share/locale/en_US.UTF-8/LC_MESSAGES/coreutils.mo", O_RDONLY) = -1 ENOENT (No such file or directory)
open("/usr/share/locale/en_US.utf8/LC_MESSAGES/coreutils.mo", O_RDONLY) = -1 ENOENT (No such file or directory)
open("/usr/share/locale/en_US/LC_MESSAGES/coreutils.mo", O_RDONLY) = -1 ENOENT (No such file or directory)
open("/usr/share/locale/en.UTF-8/LC_MESSAGES/coreutils.mo", O_RDONLY) = -1 ENOENT (No such file or directory)
open("/usr/share/locale/en.utf8/LC_MESSAGES/coreutils.mo", O_RDONLY) = -1 ENOENT (No such file or directory)
open("/usr/share/locale/en/LC_MESSAGES/coreutils.mo", O_RDONLY) = -1 ENOENT (No such file or directory)
write(2, "rm: ", 4rm: )                     = 4
write(2, "cannot remove directory `test'", 30cannot remove directory `test') = 30
open("/usr/share/locale/en_US.UTF-8/LC_MESSAGES/libc.mo", O_RDONLY) = -1 ENOENT (No such file or directory)
open("/usr/share/locale/en_US.utf8/LC_MESSAGES/libc.mo", O_RDONLY) = -1 ENOENT (No such file or directory)
open("/usr/share/locale/en_US/LC_MESSAGES/libc.mo", O_RDONLY) = -1 ENOENT (No such file or directory)
open("/usr/share/locale/en.UTF-8/LC_MESSAGES/libc.mo", O_RDONLY) = -1 ENOENT (No such file or directory)
open("/usr/share/locale/en.utf8/LC_MESSAGES/libc.mo", O_RDONLY) = -1 ENOENT (No such file or directory)
open("/usr/share/locale/en/LC_MESSAGES/libc.mo", O_RDONLY) = -1 ENOENT (No such file or directory)
write(2, ": Permission denied", 19: Permission denied)     = 19
write(2, "\n", 1
)                       = 1
close(3)                                = 0
close(1)                                = 0
exit_group(1)                           = ?
Thanks again
 
Old 03-25-2012, 07:43 AM   #45
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
I'm no strace expert but it doesn't tell me any more than I already knew
 
  


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 09:20 AM
Deleting a directory esm03 Linux - Newbie 2 06-28-2006 12:15 PM
"WARNING: Circular directory structure" error when deleting directory pistonbrew Linux - Software 5 02-03-2005 07:05 AM
Deleting a directory... closet geek Linux - General 7 07-09-2003 07:25 AM
deleting non-empty directory sadiboyz Linux - Newbie 2 04-21-2003 10:29 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie

All times are GMT -5. The time now is 11:51 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