How can I delete the cygwin folder on my c drive?
Solution 1
If you get an error that an object is in use, then ensure that you've stopped all services and closed all Cygwin programs. If you get a 'Permission Denied' error then you will need to modify the permissions and/or ownership of the files or folders that are causing the error. For example, sometimes files used by system services end up owned by the SYSTEM account and not writable by regular users.
The quickest way to delete the entire tree if you run into this problem is to change the ownership of all files and folders to your account. To do this in Windows Explorer, right click on the root Cygwin folder, choose Properties, then the Security tab. If you are using Windows XP Home or Simple File Sharing, you will need to boot into Safe Mode to access the Security tab. Select Advanced, then go to the Owner tab and make sure your account is listed as the owner. Select the 'Replace owner on subcontainers and objects' checkbox and press Ok. After Explorer applies the changes you should be able to delete the entire tree in one operation.
If you want to be thorough you can delete the registry tree Software\Cygwin under HKEY_LOCAL_MACHINE and/or HKEY_CURRENT_USER. However, if you followed the directions above you will have already removed everything important. Typically only the installation directory has been stored in the registry at all.
Here is the source Cygwin Link
Solution 2
Open an cmd.exe as administrator:
takeown /f "c:\cygwin" /r /d Y
The last parameter makes takeown assume yes to all questions and depends on locale. In my locale I had to answer "J" to make it work. YMMV.
icacls "c:\cygwin" /T /Q /C /reset
Finally, to delete the files after we got the relevant permissions:
rd "c:\cygwin" /s /q
See https://serverfault.com/questions/43794/using-icacls-to-set-permissions-on-user-directories and http://lallousx86.wordpress.com/2009/06/14/resetting-ntfs-files-security-and-permission-in-windows-7/
Hope this works for you.
Solution 3
Go to properties of folder > security tab > Advanced > Owner tab > Edit > select the new owner and check the checkbox "replace owner on subcontainers and objects" > Apply > Ok > now give full control to everyone from permissions tab and then delete the folder
Related videos on Youtube
Michael
Updated on September 18, 2022Comments
-
Michael over 1 year
Hopefully a quick question:
If I have a scenario where I have a car that can be rented out, which route would I use to view the booking for a car:
/bookings/car/:carID
Or
/cars/:carID/bookings
I can see how either can work but which one is a better way, because it’s booking that it’s returning should be via the Booking end point rather than the Car endpoint.
I think it reads better by navigating into the Car endpoint and then into bookings.
-
Admin over 11 yearsYou might need to use the
sudo
command, which is the *nix super user invocation.
-
-
dub stylee almost 9 yearsI had tried taking ownership, etc. and this is what finally worked for me! Thanks.
-
Damian about 7 yearsExcellent answer! could delete the cygwin folder after this.
-
jony almost 7 yearsThis certainly worked for me too (and I thought I had tried pretty much everything everything by now!).
-
Pysis over 6 yearsLifesaver! Had this issue for many years, in different ways. With the Cygwin folder itself when re-applying Windows OS installations, and/or moving them to new hard disks, and tonight, when I was simply creating folders with
rsync
inside of a Cygwin that I had installed fresh with my current OS install... -
Pysis over 6 yearsaaaaand now, somehow, I've entered a worse scenario where performing the same action, while now using an fstab with
noacls
added, creates a folder where the owner cannot be viewed, changed, and the steps mentioned here failed for that reason as well. -
Michael over 6 yearsVery helpful. Yeah I can see the logic, that’s what I thought as it reads in context. The thing is that the booking also contains a driver. So the booking includes a car and a driver. So the /car/5/bookings will only accept a GET request and POST will be sent to /bookings , DELETE and PATCH will be sent to /bookings/:bookingID
-
DJDaveMark over 6 years@Michael when booking a car with a driver
POST car/3/bookings
just needs the driver as one of the parameters. If you're not careful, things could start to get messy if you need to query the bookings of a driver for any cardriver/9/bookings
? Or even all bookings for the past daybookings?period=1d
? But if you wanted to filter by driver too,bookings?period=1d&driver=9
thenbookings?driver=9
should work too, shouldn't it? In my experience, refactor code to avoid code duplication. Multiple endpoints for the same thing is fine. Just keep everything organised/logical/clean. -
Michael over 6 yearsYep, that’s great! Thanks for this, has made it clear now.
-
Jay Elston over 5 yearsYou might also make mention of the problem caused because of a file named CON.cif. See this question.