How to remove Cygwin completely from Windows

Remember needing Cygwin back in the day, but after using it for my only occasion forgot the software-libraries completely? That happened to me. I have installed Windows 7 again and found my C:cygwin folder with all the files. Wanted to get rid of it, but no way – a mysterious “permission denied” when deleting the files. It seems there’s no way to remove it. Cygwin protects the files with some security stuff. That’s just idiotic, having no access to my own files!

I’m always logged in as native Administrator – no other users present. What I tried next was to navigate to that folder through my Linux machine (CIFS mounted filesystem), but got “permission denied” error there as well, even with the magic command:

sudo rm -rf /media/windows/cygwin

Here’s how to remove Cygwin once and for all.

You will need

  • Cygwin
  • cmd.exe
  • 2 minutes

Run cmd, navigate to C: (or another disk, if you have installed it in a different path).

This command takes ownership recursive of the folder, without asking anything:

takeown /r /d y /f cygwin

This command gives Full Access to Everyone recursively in the folder:

icacls cygwin /t /grant Everyone:F

And finally, the command which deletes it all and removes Cygwin:

rmdir /s /q cygwin

Good bye, Cygwin!

Want to write with me?

Do you know something about tech, nerdy stuff, movies, code, AI, Internet phenomena, social media or anything related to geeky subjects? Join and write with me! I'm currently doing this alone and my time is not sufficient for upkeeping the blog by myself, so all pieces of articles are welcome. Contact me and get your user account.

Roni Laukkarinen

Roni Laukkarinen

Editor-in-chief and owner of Geeky Lifestyle blog. Truly a jack of all trades, a Swiss knife; an avid tech and multimedia geek, coder, owner of a digital agency company, sysadmin, music enthusiast, artist and film critic.

33 comments

  1. Nguyen Vo

    Thank you. Can you tell me how to come up with this solution?

    Reply to this comment
    1. Roni Laukkarinen

      Roni Laukkarinen

      I usually find every solution by experimenting, this was no different. 🙂 I trust in the power of command line!

      Reply to this comment
      1. Xavier

        I do the same. Unlikely so, your method did not work for me because Cygwin was no longer working on my PC (my PC has crashed several times after I left it), So instead of all those 3rd Party apps, I experimented.

        What I did was, I used the inbuilt system of Windows (properties). Then the Security tab, and I found that I could not change the permissions for now. Then I went to Advanced, then to Owner tab, to find that the ownership was set to my previous account (one that I used before my system crashed). I clicked on my current account and clicked apply.
        Then I went to Permissions tab, and then I found that I could grant myself Full Control over the folder. Yay!
        Then I deleted it, once and for all.

        I feel you should also add this method to the list, for the needy. Even though the post is about an year old.

        Reply to this comment
  2. Paul

    This worked perfectly!!!! Well Done and Thank You.

    Reply to this comment
  3. Roni Laukkarinen

    Roni Laukkarinen

    Glad you liked it!

    Reply to this comment
  4. Francis

    Hi:

    I tried it but the bin and etc directories remain. I can’t even open the etc directory.

    Reply to this comment
  5. Francis

    Hi, I got rid of them once I killed the bash process that was running. Thanks for the great information. Much appreciated.

    Reply to this comment
    1. Roni Laukkarinen

      Roni Laukkarinen

      No probs! Great that you got it solved!

      Reply to this comment
  6. Leo

    Good job. What I need is the procedure.

    Reply to this comment
  7. needizTeam

    Hi, we had trouble with “takeown” and Administrator rights, so we fund this workaround:
    – connect with an account which is Administrator (no need of Super Administrator): for example, my-windows-account
    – open cmd with the option “execute as admin”
    – execute: takeown /A /r /d y /f cygwin (/A gives ownership to admin group)
    – execute: icacls cygwin /t /grant:r my-windows-account:F (:r to force/impose new ownership)
    – execute: rmdir /s /q cygwin
    Thx Roni for your post.

    Reply to this comment
  8. AG

    Nice one. It completly removed CYGWIN from my windows 7

    Reply to this comment
  9. no thanks

    just stop the sshd.exe windows service

    Reply to this comment
  10. Rizwan

    I haven’t run the takeown command but did run the last two commands. Is it still hiding inside my registry (win7)?

    Reply to this comment
  11. Yearlync

    Thanks you , it work like a charm and it’s not even 2 mins!! hehe

    Reply to this comment
  12. Dude

    Thanks, it deleted all the files except for the “7-Zip.dll” in the 7-Zip folder. except for that, all worked well

    Reply to this comment
  13. Simon

    didn’t work for me, but found another way:
    takeown /F “path of the folder where cygwin is” then hit ENTER. it gives a full access to that specific folder
    then go to that folder right click and DELETE it,

    Reply to this comment
  14. Robotnik

    Awesome. I had this huge cygwin folder that I was fighting to get rid of for several months.You solution solved in a few minutes. Thanks!

    Reply to this comment
  15. has same problem.

    run cmd, go to the parent directory of cygwin, run command ” rd -s cygwin”

    Reply to this comment
  16. dorit

    thank you! your solution worked great for me!
    2 things though, for others who try it – it takes more than 2 minutes, so if you run the command and it seems not to stop – just wait…also you should open the cmd as administrator

    Reply to this comment
  17. Xavier

    Frankly, your method did not work for me. Mainly because Cygwin was no longer working. I had installed it long ago, with a different account on my XP. But then my System crashed, and I had to recover my OS. But now the account did not exist anymore, neither the Cygwin.bat worked (tried running it through cmd too, but no success).

    I thought of trying Unlocked and Long Path Tool. None worked, as Unlocker hanged and stopped responding, whereas LPT asked for a Key (I don’t like spending money on stupid things).

    So I used my own brain. i am not even sure of what I did, I just kept trying till I succeeded.

    1- I right-clicked it and opened up the Properties. I clicked the Security tab, to find that I could not change the permissions here (I could not grant myself full control).
    2- Clicked “Advanced” and then in the “Owner” tab, I clicked my own account and then checked some box “Replace owner…”. Clicked Apply. I could not grant full control still.
    3- Went to Permissions tab. Clicked on my account name, and then ticked both boxes below, and then clicked Apply.

    Finally, I granted all accounts full access from the Security tab. Then I deleted the folder.
    That folder was taking 4 GB of space from my HDD! Phew!

    So guys, just remember to use your own brain and not to depend on 3rd party softwares. Windows has its own features, and most of the time you won’t require all those things.

    Reply to this comment
    1. Roni Laukkarinen

      Roni Laukkarinen

      Yeah, this tutorial is for those who had it on the same machine. Cygwin acts by default leaving files behind… you did practically more advanced version of my technique but using UI instead of cmd. 🙂 thanks for the advice!

      Reply to this comment
  18. equatorlounge

    hey bro, you officially are HISTORY
    I mean it, probably the guys who invented cygwin are goddam pissed right now LOOOL
    no seriously I think that’s cool cos there seems to be no other way to install node.js (something I need badly) without using cygwin

    Reply to this comment
  19. blue_floyd

    wracked my brain on this for 2 days.. tried so many things finally used your process and IT WORKS. Thanks a Lot !!

    Reply to this comment
  20. David Hicks

    the process in the article worked for me too; excellent, thank you. The first time I tried it, I accidentally overlooked the iacacls step and it didn’t work until I went back and did it as instructed

    Reply to this comment
  21. alisson menezes

    I can not run this command icacls cygwin / t / grant Everyone: F give error mapping between account names and security IDs who can help me? email me with a solution alissonmene@gmail.com

    Reply to this comment
  22. Prievidza

    if u have cygwin64:
    takeown /r /d y /f cygwin64
    icacls cygwin64 /t /grant Everyone:F
    rmdir /s /q cygwin64

    Reply to this comment
  23. Tirthadeep Roy

    i am never going to install cygwin again

    Reply to this comment
  24. akhil movva

    thanx. But check your cywin folder name in localdisk (like cygwin64). Use that one in the place cygwin in the above code.

    Reply to this comment

Leave a Reply

Your email address will not be published. Required fields are marked *

Follow The Geek

Geeky Lifestyle is a huge tweeter! Follow @thatgeekyblog to get real-time updates about what's happening in the scene.