Windows – How to stop cygwin from creating undeletable files? Or can I delete them somehow

cygwin;file-permissionspermissionswindows 7

Once in a while cygwin seem to create files that doesn't seem to be removable at all. When deleting from cygwin it just doesn't happen (rm says nothing, but the file is still there). When trying from the explorer it says that I need permissions from the administrator (and I am the administrator, the delete item in the drop down menu has a shield and I guess that means that I try this with administrator priveleges). When trying from total commander I first get error and am asked if I wan't to retry as administrator and then I still doesn't seem to have permission to delete the file.

I get the same problem if I try to view the file. Problems when I try to view the security properties – must press a shield-button to become administrator and then am told that I'm not allowed to view it unless I take ownership (which I'm not allowed to do).

Using the cygwin shell I'm allowed to view, but not modify the ACL (even if the shell is being run as the administrator):

$ getfacl makefile.wine
# file: makefile.wine
# owner: Unknown+User
# group: Unknown+Group
user::rw-
group::r--
other:---
$ setfacl -b makefile.wine
setfacl: Permission denied

However when restarted windows there were no problems in just removing the files.

Why/how do cygwin create these files (I figured out that one was created when running sed -i)? How can I avoid this? And finally is there any sane way to delete the file?

Best Answer

cygwin should not create undeletable files, at least not anymore. Assuming you have an updated installation (cygwin 2.5.1) : check the file ACLs with: getfacl "filename" you can sanitize the ACL permission with : setfacl -b "filename" See manuals of getfacl and setfacl for details. Additional reading https://cygwin.com/cygwin-ug-net/ntsec.html#ntsec-files

As you have from getfacl

owner: Unknown+User

group: Unknown+Group

It means cygwin does not recognize the owner. Two possibilities :

1) the owner is not anymore valid in the windows machine

2) you are using some type of VPN or Domain connection and the windows database user is not accessible in specific conditions.

As windows admin you should be able to change the owner, also from cygwin.

Related Question