Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Undeletable file in cygwin

Tags:

cygwin

A command I executed in cygwin hosed up a bunch of files. Now I cannot delete them. Omitting most of the 'ls' output, here is what I'm dealing with:

% ls -l
ls: cannot access WSERV001.txt: No such file or directory
-rw-r--r--  1 mccppk mkgroup-l-d   50 Sep 17 16:57 WSERV001.text
??????????? ? ?      ?              ?            ? WSERV001.txt
% rm WSERV001.txt
rm: cannot remove `WSERV001.txt': No such file or directory
% touch WSERV001.txt
touch: cannot touch `WSERV001.txt': Permission denied

The .text file is normal. The .txt file (directory entry anyway) is obviously hosed. Any ideas on how to get the .txt file deleted?

like image 816
MykennaC Avatar asked Sep 17 '10 22:09

MykennaC


2 Answers

I had the same problem and fixed it as follow (under Win7):

Open a cmd windows (run as Administrator)

takeown /r /f DRIVE:\PATH

icacls DRIVE:\PATH /grant USERNAME:F /T

where USERNAME is your win7 username under which you are running this.

Also make sure cron.exe is NOT running for user USERNAME or SYSTEM (can be checked from the TaskManager) and that no programs from cygwin are running.

Once all has been checked and done, you should be able to delete your files.

Hope this helps,

Jean

like image 123
Jean Avatar answered Jan 04 '23 06:01

Jean


I have a reproducible case and none of what is suggested here helps because of permissions restrictions.

Under sygwin:

[Sakis@t0000000000]$ ll
total 0
drwxr-x--- 1 ???????? ???????? 0 Jul  4 02:51 t0000000000_1.db/
[Sakis@t0000000000]$

Trying to take the owner from an admin cmd console:

c:\t000000000
0>takeown /r /f t0000000000_1.db
ERROR: Access is denied.

Trying to delete from an admin cmd console:

c:\t000000000
0>rmdir /S t0000000000_1.db
t0000000000_1.db, Are you sure (Y/N)? Y
Access is denied.

Cannot also change the owner from the windows GUI. It complains that you should have read permissions.

--- RESOLVED ---

Finally, I have managed to delete it by entering a cmd command with administration privileges and execute:

rm -r <dir>

TIP: You have to make sure that the directory in not used at all. You can use the procmon to find you who locks that directory.

like image 34
thanos.a Avatar answered Jan 04 '23 06:01

thanos.a