I need to use windows OS, it is my job requirements; there are certain software only run at windows. I wish I could have Linux environment so that I can have commands which helps me on doing repetitive task, command such as grep, find, less, tail are my favorites.
In order to have Linux environment, there are three ways.
1. Install Linux for dual boot.
2. Install Linux into virtual machine by using vmware, virtual box.
3. Install Linux emulator which is Cygwin.
My requirement is to use Linux commands to ease my works under Windows, therefore what I actually needs is Cygwin.
What is Cygwin?
Based on the definition from the official website, Cygwin is a Linux-like environment for Windows. Basically Cygwin helps you download a series of exe and dll, and keep under C:\Cygwin\bin, you can run almost all exe under this directory at your windows command prompt.
So what is the different between Cygwin console and windows command prompt? Cygwin initiate the bash login using command prompt, open C:\Cygwin\Cygwin.bat with notepad will reveal the secret.
This does the bash login:
bash –login -i
It is too easy that not even worth mentioning here, download a Setup.exe from cygwin official website and run, hit series of ‘Next’ button and you are done with the default setup. One thing to bear in mind is if you need to download extra package; you may need to run the setup.exe again, so don’t delete the setup.exe after the installation.
To ease the triggering setup.exe from cygwin console, you create a symlink at /usr/bin point to the setup.exe.
Let say I download my setup.exe and store at C:\
ln –s /usr/bin/cygsetup /cygdrive/c/setup.exe
Therefore when I trigger cygsetup, it will run setup.exe.
Cygwin maintain all drives in /cygdrive, /cygdrive/c indicates C: and you can change directory to C: by doing this:
Adding new package:
Same as installation, adding new package by clicking setup.exe, at the last GUI, you may type the package name you wanna install into a search text box or manually choose from the list. Just click under ‘New’ column if you choose to install.
Maybe you may ask, besides that there are a lots of Linux commands for us to use, what else is different compare to windows default dos command prompt?
Cygwin giving you are bash environment.
You have a home directory, which is /home/
You have your bashrc and bash_profile like bash in Linux.
You may execute your windows programs.
You may run the bash script; within your bash script you may execute the windows exe such as explorer, calc, regedit etc.
The path methodology is different from dos, it start with / which is a root directory. Therefore all the drives will be map under /cygdrive.
Cygpath tells you the path information.
Sometimes we need to obtain a windows path format on the current directory we are in at cygwin, can we obtain the windows path or dos path?
The answer is yes, because cygwin provides cygpath.
Let say I have traverse to ‘Program Files’, in bash the unix path is /cygdrive/c/Program Files, in order to obtain the windows path format, we can do this:
cygpath -aw .
To obtain the dos path format ( short string upto 8 characters for directories and filename)
cygpath -ad .
To convert back the windows path to unix path, you can do this:
cygpath -au “C:\Program Files”
There are more to share about how cygwin helps me in the windows environment, but for now, I rest my case.
Hope you enjoy Cygwin!