How to delete a .~lock.nnnnn.ods# file
I had a file called "ODT notes.ods" on my external drive.
I had a crash trying to use BleachBit [now runs ok after some unexpectedly required upgrades]
ODT notes.ods was open during the crash so " .~lock.ODT notes.ods#" was left behind ['orphaned'? and corrupted]
I now cannot open ODT notes.ods
I can open .~lock.ODT notes.ods# BUT it contains a text document I was working on [my notes on BleachBit!]
I suspect I have lost ODT notes.ods but I wonder whether I might get it back by deleting .~lock.ODT notes.ods#
If I do 'Delete' I get “.~lock.ODT notes.ods# can't be put in the Rubbish Bin. Do you want to delete it permanently?"
& Details > "Unable to move file to the wastebasket: No such file or directory"
I select 'Delete' again from that dialogue and get > "There was an error deleting .~lock.ODT notes.ods#." Details> "Error removing file: No such file or directory"
Terminal gives:
-desktop:~$ find .~lock.ODT notes.ods#
find: ‘.~lock.ODT’: No such file or directory
find: ‘notes.ods#’: No such file or directory
&
-desktop:~$ find .~lock.*
.~lock.TODO.05.ods# [this is another problematic lock file, but at least it shows up!]
How do I find and kill .~lock.ODT notes.ods# so I can see whether any of 'ODT notes.ods' is retrievable or whether I have to rebuild it from backup please?
Question information
- Language:
- English Edit question
- Status:
- Solved
- For:
- Ubuntu Edit question
- Assignee:
- No assignee Edit question
- Solved by:
- Nic Knox
- Solved:
- Last query:
- Last reply:
Revision history for this message
|
#1 |
What is the output of:
sudo find / | grep -i notes
Thanks
Revision history for this message
|
#2 |
Thanks - sorry for slight delay - looks like my ISP is having a bad day ...
output for "~$ sudo find / | grep -i notes" is 470+ visible lines + some that disappeared, so asked for:
nicnoks@
nic@nic-desktop:~$ sudo find / | grep -i odt\ notes
/media/
/media/
/media/
/media/
/media/
/media/
/media/
/home/nic/post/ODT notes.ods
/home/nic/
/home/nic/
/home/nic/
/home/nic/
/home/nic/
/home/nic/
/home/nic/
/home/nic/
If I should have given you the 470 lines I can do so of course.
Revision history for this message
|
#3 |
I assume the problem is the hash character in the file name
you might try
rm '/media/
or
rm /media/
to tell the shell not to use the hash character as starting of a comment.
Revision history for this message
|
#4 |
I just see that the second proposal has to be even different, with another escape character in fornt of the space sharacter
rm /media/
Another reason for not being able to delete the file might be file protections, what is the output of
ls -l .~lock.ODT*
Revision history for this message
|
#5 |
Hi, thanks again - outputs are:
rm '/media/
rm: cannot remove '/media/
rm /media/
rm: cannot remove ‘/media/
running
nic@nic-
-rw------- 1 nic nic 85 Aug 15 21:09 .~lock.ODT Notes1.ods# [rm-this is my temporary substiute file]
-rw------- 1 nic nic 98206 Aug 3 18:32 .~lock.ODT notes.ods#
For my own interest I ran your most useful 'sudo find / | grep -i .~lock'.
The output was 90 files although I only had one file open.
Does that indicate that there's actually something wrong with the '.~lock' facility?
I recently ran BleachBit which plainly hasn't tidied those up either.
Revision history for this message
|
#6 |
Can you try using the nautilus file explorer on the /media/
Revision history for this message
|
#7 |
When I took 14.04 I didn't know I would be forced into taking the Unity file manager & was quite unhappy! After a lot of huffing & puffing I got something to function a bit like Nautilus [but not as good] so I'm unsure whether I'm actually running Nautilus or Unity.
This probably makes no difference? but I mention it in case - if so what's the command to find out?
Whichever Graphical User Interface is operating gives the results set out right at the beginning of this Q. But, trying again, stepbystep:
I already have "hidden files" enabled
I hit Delete on keyboard:
"“.~lock.ODT notes.ods#” can't be put in the Rubbish Bin. Do you want to delete it permanently?" &
'Details'>"Unable to move file to the wastebasket: No such file or directory"
I hit the 'Delete' offered in the Dialogue:
"Error while deleting."&"There was an error deleting .~lock.ODT notes.ods#."
& 'Details'>"Error removing file: No such file or directory" only option offered is 'Cancel'
Thanks for your considerable patience!
Revision history for this message
|
#8 |
A message like "Unable to move file to the wastebasket: No such file or directory" is a bit weird.
Maybe you can use the following procedure as a workaround:
open a terminal window
issue "cd /media/
the command "ls -la" should list among others those .~lock* files
type
rm .~lock
and hit the tab key. What happens?
I expect that the displayed line changes into
rm .~lock.ODT\
is that the case?
Now add a small "n" and hit the tab key again. What do you get?
By using this kind of autocompletion you should be able to add the real file name including all the escape characters into the command line, and hitting 'enter' should finally remove the file.
Revision history for this message
|
#9 |
I took the precaution of closing ALL LibreOffice files b4 doing this.
the command "ls -la" DID list among others those .~lock* files:
-rw------- 1 nic nic 98206 Aug 3 18:32 .~lock.ODT notes.ods#
-rw------- 1 nic nic 1211762 Mar 9 11:46 .~lock.TODO.05.ods#
typed
rm .~lock
and hit the tab key. What happens? :-
A '.' IS ADDED AFTER '.~lock.' THAT'S ALL.
If I DOUBLE hit the TAB I get these changes:
/media/
rm: cannot remove ‘.~lock’: No such file or directory
/media/
.~lock.ODT notes.ods# .~lock.TODO.05.ods# [rm THE TODO.O5 file IS ONE OF THE 90 MENTIONED IN #5 ABOVE]
I DO NOT GET 'rm .~lock.ODT\' [rm DOES NOT PRECEDE OUTPUT & '#' NOT REPLACED BY '\']
Now add a small "n" and hit the tab key again. What do you get?
TRIED:
/media/
rm: cannot remove ‘.~lockn’: No such file or directory
AND
/media/
rm: cannot remove ‘.~lock.n’: No such file or directory
Revision history for this message
|
#10 |
Ok, the files matching .~lock* in that directory are different from what I expected.
My fault, apparently I did not see the difference between ODT and TODO in its file name.
Try again,
cd /media/
and type
rm -v .~lock.O
and hit the tab key.
What do you see now?
What do you get if you hit 'Enter'?
Revision history for this message
|
#11 |
OK:
/media/
TAB converts it to:
"/media/
ENTER returns:
rm: cannot remove ‘.~lock.ODT ’: No such file or directory
I have also been trying other things:
/media/
GIVES
.~lock.ODT notes.ods#
.~lock.TODO.05.ods#
BUT
/media/
GIVES
rm: remove regular file ‘.~lock.
rm: cannot remove ‘.~lock.
/media/
Same problem but what's going on? NO SUCH FILE? BUT 'find' FINDS IT .... has the file got another name that is not the name found by find??
someone suggested:
rm -fi ~lock.TODO.05.ods#
Is that worth a try?
Revision history for this message
|
#12 |
If the tab key expands the file name to "/media/
What is the output of
ls -la /media/
Revision history for this message
|
#13 |
I get this:
nic@nic-desktop:~$ ls -la /media/
-rw------- 1 nic nic 85 Aug 18 11:02 /media/
-rw------- 1 nic nic 98206 Aug 3 18:32 /media/
WITH CURRENT NOTES FILE CLOSED I GET THIS:
-rw------- 1 nic nic 98206 Aug 3 18:32 /media/
Revision history for this message
|
#14 |
Ok, understood.
With all notes files closed, try again
cd /media/
and type
rm -v .~lock.O
and hit the tab key.
What do you see now?
What do you get if you hit 'Enter'?
Revision history for this message
|
#15 |
I get:
nic@nic-
[rem TAB added 'DT\ notes.ods#] ...... output after ENTER:
rm: cannot remove ‘.~lock.ODT notes.ods#’: No such file or directory
Revision history for this message
|
#16 |
I had expected that there is a backslash character inserted in front of the hash, but I do not see that in your output.
It seems that the attempts with tab expansion will not lead to success.
Two new ideas:
1. you could try deleting the file using wild cards, execute (when you do not have any other notes files open) the following command
rm -v .~lock.
2. You maybe have a file system error, that the file is only shown in the directory, but does not exist on the disk. Is this an external storage medium, that you can unmount and run fsck on it?
Revision history for this message
|
#17 |
Thanks once again:
1. rm -v .~lock.
AGAIN GIVES
rm: cannot remove ‘.~lock.ODT notes.ods#’: No such file or directory
2. Yes, "exdrive" is an external HD,
but sorry to be thick ... I can see the disc on the list if, on UNITY I go to Applications>
Revision history for this message
|
#18 |
fsck has to be done from the command line.
what is the output of the commands
fdisk -l
mount
Revision history for this message
|
#19 |
nic@nic-desktop:~$ fdisk -l
nic@nic-desktop:~$ mount
/dev/sda1 on / type ext3 (rw,relatime,
proc on /proc type proc (rw)
sysfs on /sys type sysfs (rw,noexec,
none on /sys/fs/cgroup type tmpfs (rw)
none on /sys/fs/
none on /sys/kernel/debug type debugfs (rw)
none on /sys/kernel/
udev on /dev type devtmpfs (rw,mode=0755)
devpts on /dev/pts type devpts (rw,noexec,
tmpfs on /run type tmpfs (rw,noexec,
none on /run/lock type tmpfs (rw,noexec,
none on /run/shm type tmpfs (rw,nosuid,nodev)
none on /run/user type tmpfs (rw,noexec,
none on /sys/fs/pstore type pstore (rw)
binfmt_misc on /proc/sys/
systemd on /sys/fs/
gvfsd-fuse on /run/user/1000/gvfs type fuse.gvfsd-fuse (rw,nosuid,
Revision history for this message
|
#20 |
Sorry, my fault, should have been
sudo fdisk -l
mount
but please execute the command with the external device plugged in
Revision history for this message
|
#21 |
Could boot to live Ubuntu CD and delete the file there (may be stupid enough to work)
Revision history for this message
|
#22 |
1] Almost certainly not as stupid as me! ... apologies - I'm not very competent. 'Boot to a live Ubuntu CD' would that involve intervening at switch-on & changing BIOS? I don't have 14.04 on CD, but do have a 9.04 disk. As said way up this chain; in poking around I've found 90 orphaned .~lock files, so there are lots to be rid of [ I imagine something strange has happened at some time.]
2] with the external device plugged in [auto-mounted]:
sudo fdisk -l
mount
nic@nic-desktop:~$ sudo fdisk -l
[sudo] password for nic:
Disk /dev/sda: 20.5 GB, 20496236544 bytes
255 heads, 63 sectors/track, 2491 cylinders, total 40031712 sectors
Units = sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk identifier: 0xbebf116c
Device Boot Start End Blocks Id System
/dev/sda1 * 63 38266829 19133383+ 83 Linux
/dev/sda2 38266830 40017914 875542+ 5 Extended
/dev/sda5 38266893 40017914 875511 82 Linux swap / Solaris
Disk /dev/sdb: 40.0 GB, 40020664320 bytes
255 heads, 63 sectors/track, 4865 cylinders, total 78165360 sectors
Units = sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk identifier: 0xafacafac
Device Boot Start End Blocks Id System
/dev/sdb1 * 63 78140159 39070048+ 7 HPFS/NTFS/exFAT
Disk /dev/sdd: 80.0 GB, 80026361856 bytes
255 heads, 63 sectors/track, 9729 cylinders, total 156301488 sectors
Units = sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk identifier: 0x2052474d
This doesn't look like a partition table
Probably you selected the wrong device.
Device Boot Start End Blocks Id System
/dev/sdd1 ? 6579571 1924427647 958924038+ 70 DiskSecure Multi-Boot
/dev/sdd2 ? 1953251627 3771827541 909287957+ 43 Unknown
/dev/sdd3 ? 225735265 225735274 5 72 Unknown
/dev/sdd4 2642411520 2642463409 25945 0 Empty
Partition table entries are not in disk order
Revision history for this message
|
#23 |
I assume the external device with the offending file is sdb, with the partition sdb1 formatted as NTFS.
Running a file system check would require to unmount the drive and then run
sudo fsck -v -f -c /dev/sdb1
Another possibility would be to plug this device into a Windows computer and trying to either delete the offending file there, or running chkdsk on Windows.
Revision history for this message
|
#24 |
I'm sure sdb is a disk I had to install to rescue its data from a microsoft disaster on my wife's pc.
It must be sdd we're concerned with, so does your kind help above apply given the " Device Boot Start End Blocks Id Systems" data?
Please confirm the command line input before I do more
many thanks
Revision history for this message
|
#25 |
The command "mount" with the device plugged in should clearly show the device that is behind the ...exdrive directory
Revision history for this message
|
#26 |
I think that looks like sdd [on last line?]:
nic@nic-desktop:~$ mount
/dev/sda1 on / type ext3 (rw,relatime,
proc on /proc type proc (rw)
sysfs on /sys type sysfs (rw,noexec,
none on /sys/fs/cgroup type tmpfs (rw)
none on /sys/fs/
none on /sys/kernel/debug type debugfs (rw)
none on /sys/kernel/
udev on /dev type devtmpfs (rw,mode=0755)
devpts on /dev/pts type devpts (rw,noexec,
tmpfs on /run type tmpfs (rw,noexec,
none on /run/lock type tmpfs (rw,noexec,
none on /run/shm type tmpfs (rw,nosuid,nodev)
none on /run/user type tmpfs (rw,noexec,
none on /sys/fs/pstore type pstore (rw)
binfmt_misc on /proc/sys/
systemd on /sys/fs/
gvfsd-fuse on /run/user/1000/gvfs type fuse.gvfsd-fuse (rw,nosuid,
/dev/sdd on /media/nic/exdrive type fuseblk (rw,nosuid,
If it is sdd please confirm correct command line [as per thread 23]
thanks
Revision history for this message
|
#27 |
Sorry, I do not have enough experience with ntfs disks mounted as fuse file system, that I would dare to give commands to manipulate that disk. The output of the "sudo fdisk -l" command with "This doesn't look like a partition table" also looks a bit suspicious.
I want to recommend that you try plugging this disk into a Windows system to check what you see there, and eventually try deleting the file from within Windows.
Revision history for this message
|
#28 |
Thank you for your time and effort, shame it didn't work out.
I shall try the Windows route when I have access to Windows.
For the record I just tried:
rm -fi .~lock.ODT\ notes.ods*
ALL IT RETURNED WAS:
rm: remove regular file ‘.~lock.ODT notes.ods#’? y
rm: cannot remove ‘.~lock.ODT notes.ods#’: No such file or directory
Revision history for this message
|
#29 |
To complete this Q.
m-hampl suggested "Another possibility would be to plug this device into a Windows computer and trying to either delete the offending file there, or running chkdsk on Windows."
Once I had found a Windows pc that would read the drive I tried to Delete: 'file not found'
then as suggested tried chkdsk [find & fix]. It did indeed find the orphans and said it fixed them, but they were still there
BUT
Nautilus was able now to move them to Rubbish Bin, so issue resolved.
Unfortunately [almost as expected] the parent [ODT notes.ods] was still terminally damaged.
Moral - never use Bleachbit while files are open?
I don't know how you would remove .~lock files if Windows could not read your drive.
Revision history for this message
|
#30 |
ADDENDUM:
This bug relating to .~lock files persists however the parent files usually now remain undamaged. The .~lock file can sometimes be opened but it's contents are nothing to do with the parent file: they relate to something else that was open at the time.
I have found another workaround which works for my external HD:
Mount the drive carrying the orphaned .~lock files to Windows7 > then invoke '.~lock' in 'Search' within the directory containing the orphaned .~lock files. The search process seems to purge the the orphaned .~lock files as it reports 'can't be found' and sure enough they are missing from 'Explore'. On remounting to the Linux OS they are still missing.