Take the 2-minute tour ×
Ask Ubuntu is a question and answer site for Ubuntu users and developers. It's 100% free, no registration required.

I have a directory in my home dir, but I am unable to remove it in any ways.

Using rm -rf JsZ-r6K.50/ crashes the konsole. I also tried to use sudo rm, but it is the same.

drwxr-xr-x  3 volkan volkan     4096 Nov  5 03:19 .installjammerinfo/
drwxrwxr-x  4 volkan volkan     4096 Aug  6 15:28 .java/
drwxr-xr-x  2 volkan volkan 86122496 Nov  8 22:25 JsZ-r6K.50/
drwx------  5 volkan volkan     4096 Nov  8 02:58 .kde/

How can I remove this directory?

EDIT:

volkan@ubuntu:~$ lsattr -d JsZ*
----------I--e-- JsZ-r6K.50

EDIT for OmPs:

I moved the file into /var/tmp/newname, but I cannot remove it from there either. The following commands failed also, they freezed the console.

Only the lsof command gave the following:

COMMAND  PID   USER   FD   TYPE DEVICE SIZE/OFF   NODE NAME
bash    3935 volkan  cwd    DIR    8,6 86122496 914129 new
rm      4177 volkan    3r   DIR    8,6 86122496 914129 new
rm      4177 volkan    4r   DIR    8,6 86122496 914129 new
share|improve this question
    
Could you please try also lsattr -d Jsz* and put the result here? Sound at corruption, maybe the immutable flag has been set... –  Rmano Nov 8 '13 at 23:08
1  
Updated the question with lsattr –  wakeup Nov 9 '13 at 0:17
    
Seems normal. I still vote for some pesky thing. Probably you will have an error in your syslog files when the terminal crashed. Have you tried to remove the directory from a virtual console? (Ctrl-Alt-F1, login, try to remove the dir --- note any error. Alt-F7 or Ctrl-Alt-F7 to go back to the graphical environment.) –  Rmano Nov 9 '13 at 0:53
    
A question more: do you remember how you created it, or how it appeared? I suggested changing a bit the title to reflect this, to make it more generally interesting (for example, how to remove a strange-looking directory that appeared by itself or something of the style...) –  Rmano Nov 9 '13 at 0:56
1  
@Rmano I don't remember actually. I just realized it today. Changed the title. Thanks. –  wakeup Nov 9 '13 at 1:00

3 Answers 3

up vote 3 down vote accepted

Warning, what's below is quite dangerous, backup your data before :

You may have a script running into that folder... (your lsof show a bash command)

be sure to be out of the folder and with administrative rights (sudo or root.)

Kill all possible process that access to that folder :

kill -9 `lsof -t /MyFolder`

then you'll be able to remove it :

rm -rf /MyFolder

MyFolder being the folder you want to be removed.

If it doesn't work, please show us what the mount command output

Best regards.

share|improve this answer
    
Yes. Thank you. Probably killing all tasks solved the problem!! Now its gone! –  wakeup Nov 10 '13 at 18:06
    
It is still very strange that the script was running even after a full checkup and a restart. But +1 for thinking about lsof, although it's quite strange the fact that trying to remove the file freezed the system. –  Rmano Nov 11 '13 at 15:25
1  
maybe the script / process was looking for something inside that folder. There may be many reasons (like incron, backup or data cloud software, ...). Just in case (but quite remote possibility) : he needs to check his system for some virus or rootkit with clamav + rkhunter. –  Antoine Rodriguez Nov 11 '13 at 16:41

This is really strange --- it seems a corrupted entry (the link count is very very suspicious). What I would do is firstly, a backup and then try to force a check of the disk on the next reboot.

Notice that it's very important to do a backup of all the data you have in the partition if you suspect that this could be a disk corruption.

To force a filesystem check for the next reboot, first identify the device; from the directory, df ., would say something like this:

(0)samsung-romano:~% df .
Filesystem     1K-blocks      Used Available Use% Mounted on
/dev/sda6      503315720 140840260 336901780  30% /home

So the device is /dev/sda6. Now force a check in the next reboot. There are various way to do it, what I use normally is to force a high mount count on the device, like

sudo tune2fs -c 100 /dev/sda6 
sudo tune2fs -C 100 /dev/sda6 

The first one says to check the filesystem on the device once every 100 mount, and the second one set the mount-count to 100, so next boot it will be checked.

The most probable thing is that the check will detect it and remove it/move to the lost+found directory in the root of the filesystem (in my case it would be /home/lost+found/). From there it is normally possible to remove it.

share|improve this answer
    
I executed those. I will restart and tell you the results. –  wakeup Nov 9 '13 at 1:02
    
Restarted, but it is still there. –  wakeup Nov 9 '13 at 16:45
    
It would be really useful to capture the error when trying to remove it. Something should appear --- in /var/log/syslog, in ~/.xsession-errors, in dmesg... –  Rmano Nov 10 '13 at 0:11
    
What should I look for exactly? Something like cat /var/log/syslog | grep -i "rm"? –  wakeup Nov 10 '13 at 4:36
    
What I normally do to monitor the relevant files is (apart using a little program I wrote you can find in sourceforge) is opening various terminal and run tail -f /var/log/syslog (change with other interesting log files) in it. –  Rmano Nov 11 '13 at 15:28

I would suggest try moving it to some different location.

mv /path/to/filename /var/tmp/newname

if this works i think you are done, and can remove it from there.

also try doing a

file /path/to/filename

this should tell you what kind of file it is. if nothing works. try

cp /dev/null /path/to/filename
rm /path/to/filename

this will make the file with 0 bytes and then you can eaisly remove it.

to check why removing this file is crashing your terminal.

lsof /path/to/filename

this will list all the processes on the systems using this file. you can stop those processes and remove then try deleting the file again.

share|improve this answer
    
Edited the question. –  wakeup Nov 10 '13 at 16:58
    
try killing the PID's which are using that file. after that run lsof again on that file to confirm it is not being used by any other process and then run rm command. hope that helps. –  OmPS Nov 10 '13 at 18:17

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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