You are not logged in.

#1 2008-09-04 08:41:07

yehdev_cc
Member
Registered: 2008-06-03
Posts: 26

I can't delete this file !!

Hi,
Actually I'm really facing a very strange situation..
It happened that I have a file that all the permissions it has is that it can be read by its owner..
and to make it even more odd, the owner is 'root'...
I can't figure a way to remove this file, but I really have to..
It all started when I tried to remove a probable virus file from a 'ntfs' partition..
but when I mounted this partition, I found that I can't delete this file...
Oh, I forgot to say that I couldn't delete it from windows either, so ???
Any help is appreciated ..
thanx in advance..

Offline

#2 2008-09-04 08:54:58

richs-lxh
Member
Registered: 2008-08-23
Posts: 76

Re: I can't delete this file !!

Have you got read/write permissions for the ntfs partition? This would explain why you can't delete it from Linux.

If you mount the ntfs partition with r/w, you can issue the

sudo rm -f

command to force a delete.

Basically, you create a folder to mount the partition to, then add the ntfs partition and mount directory to your fstab.

Something like this:(if your ntfs partition is hda1)

/dev/hda1 /media/hda1 ntfs defaults 0 0

You'll need the ntfs-3g driver installed to obtain write access to the ntfs drive, it's in the repositories.

There are free programs available for Windows which will remove problem files:
http://ccollomb.free.fr/unlocker/

richs-lxh

Last edited by richs-lxh (2008-09-04 08:58:28)

Offline

#3 2008-09-04 09:03:09

yehdev_cc
Member
Registered: 2008-06-03
Posts: 26

Re: I can't delete this file !!

Thank you for your reply..
Actually yes, I can write to the disk normally, except for this file because of its permissions that grant no more than the ability to read to its owner... no more no less !! roll
???!!

Offline

#4 2008-09-04 17:31:03

richs-lxh
Member
Registered: 2008-08-23
Posts: 76

Re: I can't delete this file !!

Ok, so you just change the ownership of the file.

To change the owner:

sudo chown yehdev_cc:yehdev_cc /windows/system32/bad_file.dll

To get write permissions:

sudo chmod 755 /windows/system32/bad_file.dll

The other way, in Kde and Gnome, is to mount your file browser as root and just go looking for the file and delete it.

To open a graphical app as root:
kdesu app (kde)

kdesu konqueror

gksudo app(Gnome)

gksudo nautilus

richs-lxh

Last edited by richs-lxh (2008-09-04 17:38:05)

Offline

#5 2008-09-04 18:10:38

moljac024
Member
From: Serbia
Registered: 2008-01-29
Posts: 2,676

Re: I can't delete this file !!

Just mount it with ntfs-3g and purge it with shred!

man ntfs-3g
man shred

The day Microsoft makes a product that doesn't suck, is the day they make a vacuum cleaner.
--------------------------------------------------------------------------------------------------------------
But if they tell you that I've lost my mind, maybe it's not gone just a little hard to find...

Offline

#6 2008-09-04 21:14:03

yehdev_cc
Member
Registered: 2008-06-03
Posts: 26

Re: I can't delete this file !!

Thank you for the replies...
@richs-lxh : The problem is that I don't have the permission to change the owner or the permissions.. even the owner of the file (it's the 'root') doesn't have this permission!!

@moljac024: I didn't get what you mean... what's this supposed to do ?

Offline

#7 2008-09-04 21:56:50

richs-lxh
Member
Registered: 2008-08-23
Posts: 76

Re: I can't delete this file !!

yehdev_cc wrote:

Thank you for the replies...
@richs-lxh : The problem is that I don't have the permission to change the owner or the permissions.. even the owner of the file (it's the 'root') doesn't have this permission!!

If you mount the ntfs partition, change ownership and make it writeable, you can do whatever you want to any file. Root is God wink

Ok, so go for installing ntfs-3g.

Now mount the partition to a directory called /windows.

You can chown the owner of the entire partition recursively with the -R switch. For example:

su to root

su

make a mount directory

mkdir /windows

backup fstab before editing

cp /etc/fstab /etc/fstab_backup

open fstab with nano

nano fstab

copy and paste this code (change hda1 to your windows partition) Then "ctrl+X" to exit "Y" to save and "Enter" to quit.

/dev/hda1 /windows ntfs defaults 0 0

mount all partitions

mount -a

change owbnership to root, recursively, every single file (may take a few minutes)

chown -R root:root /windows

add write permissions, recursively, every single file (may take a few minutes)

chmod -R 755 /windows

Now go and delete the file. If you can't delete the file I would really like some further information on what virus it is/was, as I have never had any Windows file which I couldn't remove as root.

PS: If you have "System Restore" enabled on Windows, disable it and delete it. It's the first place where all the nasties go to hide, and then reinfect the system later.

richs-lxh

Last edited by richs-lxh (2008-09-04 21:58:59)

Offline

#8 2008-09-05 09:41:09

chimeric
Member
From: Munich, Germany
Registered: 2007-10-07
Posts: 254
Website

Re: I can't delete this file !!

richs-lxh wrote:

change owbnership to root, recursively, every single file (may take a few minutes)

chown -R root:root /windows

add write permissions, recursively, every single file (may take a few minutes)

chmod -R 755 /windows

You most probably not want to do the above, if, then just do that recursively for the directory tree the file resides in, but not for the whole disk!! My strongest guess on why you can't delete it under Windows is that it's probably used by a process, and you probably can't delete it under Linux because the directory permissions don't allow you to do that. I'd suggest to start windows in failsafe mode, without GUI, just a shell session and then remove the file (worked most of the time for me).

Offline

#9 2008-09-05 12:05:18

richs-lxh
Member
Registered: 2008-08-23
Posts: 76

Re: I can't delete this file !!

chimeric wrote:

You most probably not want to do the above, if, then just do that recursively for the directory tree the file resides in, but not for the whole disk!!

Why not exactly? It only takes a few minutes more. Whatsmore, in my experience, if there is one infection, there is more than likely a few more hidden away in other directories. Hence the reason of taking ownership and write permissions for the entire OS in one go. Saves having to add another directory tree later.

My strongest guess on why you can't delete it under Windows is that it's probably used by a process, and you probably can't delete it under Linux because the directory permissions don't allow you to do that.

No need to guess, that is an absolute certainty. This is why I offered the link for the file-deleter. It will remove the file at boot before the process is started. Whatsmore, on top of that, safe mode will not guaruntee that you will get access to an .exe file (virus) which has attached itself to a system file which will start even in safe mode.

I'd suggest to start windows in failsafe mode, without GUI, just a shell session and then remove the file (worked most of the time for me).

Most of the time isn't very reassuring. What I have proposed has worked every time. I have been unlucky enough to have to clean a lot of (other people's) infected Windows boxes. I have always performed the task from Linux after taking control of the Windows partition.

richs-lxh

Last edited by richs-lxh (2008-09-05 12:05:43)

Offline

#10 2008-09-05 12:27:53

chimeric
Member
From: Munich, Germany
Registered: 2007-10-07
Posts: 254
Website

Re: I can't delete this file !!

richs-lxh wrote:
chimeric wrote:

You most probably not want to do the above, if, then just do that recursively for the directory tree the file resides in, but not for the whole disk!!

Why not exactly? It only takes a few minutes more.

I just fail to see why one should do that just to get rid of one file. If that worked for you in the past, then good, but IMHO it's not needed. After all, are you really sure that all files on his partition should be owned by root exclusively? Just my 2cents.

richts-lxh wrote:

Most of the time isn't very reassuring.

If it would have worked every time for me, I'd said so. All I did was suggesting another possible method wink. Not more not less. I hope that's OK.

Offline

#11 2008-09-05 16:19:12

moljac024
Member
From: Serbia
Registered: 2008-01-29
Posts: 2,676

Re: I can't delete this file !!

Is changing ownership to root really necessary ? Just open up a root shell or a file manager with root privileges and try to delete it.

The shred command that I mentioned makes it really hard for the file to be recovered (it overwrites it a few times, while a normal "delete" just removes the link to the data, kind off. It's hard to explain).


The day Microsoft makes a product that doesn't suck, is the day they make a vacuum cleaner.
--------------------------------------------------------------------------------------------------------------
But if they tell you that I've lost my mind, maybe it's not gone just a little hard to find...

Offline

#12 2008-09-05 19:14:40

richs-lxh
Member
Registered: 2008-08-23
Posts: 76

Re: I can't delete this file !!

chimeric wrote:
richs-lxh wrote:
chimeric wrote:

You most probably not want to do the above, if, then just do that recursively for the directory tree the file resides in, but not for the whole disk!!

Why not exactly? It only takes a few minutes more.

I just fail to see why one should do that just to get rid of one file. If that worked for you in the past, then good, but IMHO it's not needed. After all, are you really sure that all files on his partition should be owned by root exclusively? Just my 2cents.

I am just trying to save the guy some time, when he has to remove future viruses (which I am sure he will have too). I see your point, but as I said, on a Windows box, if there is one infection, you can almost guaruntee that there are more.

I cleaned up a box for a mate once, he said that it was running a bit slow. Over 500 infected files. Granted that many were duplicates in the System Restore directory, and others were harmless spyware, but he had some juicy little buggers hidden in there as well.

richts-lxh wrote:

Most of the time isn't very reassuring.

If it would have worked every time for me, I'd said so. All I did was suggesting another possible method wink. Not more not less. I hope that's OK.

Yeah, point taken. Very OK. There is always more than one way to skin a cat wink

I have just found that it's sometimes quicker in the long run to have "access-all-areas" instead of going through the same permission problems again for seperate directory trees. Just as if a system is completely borked, I reinstall, others would tinker and try to fix. I like all or nothing.

richs-lxh

Offline

#13 2008-09-06 00:28:01

yehdev_cc
Member
Registered: 2008-06-03
Posts: 26

Re: I can't delete this file !!

Thank you very much for the replies... I really do appreciate them..
First, I managed to remove the file from windows by using the program recommended by 'richs-lxh', after a reboot...
Second, the previous solutions failed under Linux, and I think the reason is obvious.. to change the permission and/or ownership of a certain file, you should have the permission to write to it.. and since I don't... I couldn't..
It was really a a very odd situation because:
1) The file is owned by 'root'
2) The owner can ONLY read the file !!
3) and of course no other one have this permission
It's good that it was on NTFS partition and I got that program, but think about it if it's an ext3 partition, what would be the solution ? (yes, I know that even an idiot wouldn't get stuck this way, but just think) may be we can use the ext3 program for windows that doesn't care much about permissions...may be..

Offline

#14 2008-09-06 08:09:18

richs-lxh
Member
Registered: 2008-08-23
Posts: 76

Re: I can't delete this file !!

I'm glad you got it solved yehdev_cc.

Although I am pretty certain that with ntfs-3g (installed and enabled/configured) you would have been able to delete it, as you would have had write permissions as well (which are needed to delete files).

By the way, just as an addition (in case spmebody else is reading this thread, with the same problem). Sometimes you need to right click the file form linux and edit the permissions there, usually as root via gksudo nautilus.

richs-lxh

Offline

#15 2008-10-03 01:48:30

Reploid
Member
From: Cold Country up North
Registered: 2008-03-27
Posts: 110

Re: I can't delete this file !!

Can I hijack this thread with another file that won't let it delete itself? Seeing as this thread shows up when I am searching for a solution, and the original problem got solved, I thought I could add one problem here.

Running ls -la in my home folder (username: yo)
dr-x------  2 yo   users         0 2008-10-03 00:13 .gvfs

Running ls -la as su:
d?????????  ? ?    ?             ?                ? .gvfs

I can't chmod it, chown it, rm -r it, nothing works.

I have no idea what kinda file this is, and I get this error message when I am logging in from GDM, that the session can't be saved, because I don't have write permissions to my entire home folder. Now ain't that cool, huh?

(going offline for a few hours, don't get upset if I don't reply right away. big_smile )

Offline

#16 2008-10-03 02:10:13

mrunion
Member
From: Jonesborough, TN
Registered: 2007-01-26
Posts: 1,938
Website

Re: I can't delete this file !!

Don't delete that file......it's part of the Gnome Virtual File System.


Matt

"It is very difficult to educate the educated."

Offline

#17 2008-10-03 02:27:18

dmz
Member
From: Sweden
Registered: 2008-08-27
Posts: 881
Website

Re: I can't delete this file !!

mrunion wrote:

Don't delete that file......it's part of the Gnome Virtual File System.

But, If I really want to delete it? cool

Offline

#18 2008-10-03 02:50:30

Reploid
Member
From: Cold Country up North
Registered: 2008-03-27
Posts: 110

Re: I can't delete this file !!

Yeah! Yeah! Tell us! big_smile

Offline

#19 2008-10-03 05:09:35

dav7
Member
From: Australia
Registered: 2008-02-08
Posts: 674

Re: I can't delete this file !!

Try 'mount'. Among the output, you'll see that .gvfs is actually a virtual disk per se mounted using FUSE. It isn't an ordinary directory. It's used in GNOME for 345685928325 things I have no idea about.

Delete that... and then have fun fixing your system, if you must.

-dav7


Windows was made for looking at success from a distance through a wall of oversimplicity. Linux removes the wall, so you can just walk up to success and make it your own.
--
Reinventing the wheel is fun. You get to redefine pi.

Offline

#20 2008-10-06 15:20:54

mrunion
Member
From: Jonesborough, TN
Registered: 2007-01-26
Posts: 1,938
Website

Re: I can't delete this file !!

@dmz: If you really want to delete it I guess you could remove Gnome from the system?!? big_smile


Matt

"It is very difficult to educate the educated."

Offline

#21 2008-10-06 15:21:51

dmz
Member
From: Sweden
Registered: 2008-08-27
Posts: 881
Website

Re: I can't delete this file !!

mrunion wrote:

@dmz: If you really want to delete it I guess you could remove Gnome from the system?!? big_smile

That's no fun. sad

Offline

Board footer

Powered by FluxBB