Launching and using Cygwin
Once you have launched Cygwin you can start typing commands as if you would do in a Linux terminal. However, you should note that just like it is the case in Linux, the initial directory is a virtual folder called /home/username.
The image below shows the result of running the following commands in my recently finished Cygwin installation.
Print current date:
$ echo "Today is $(date +%F)"
The initial directory is found inside a folder named home that is located in the directory where Cygwin was installed (/cygdrive/c = C:\Cygwin\home in my case):
$ pwd
Change directory to the root of the C:
drive:
$ cd C:
Create a directory:
$ mkdir 'C:\Users\Gabriel\test'
Redirect the output of the command to a file:
$ ls -l > 'C:\Users\Gabriel\test\files.txt'
View contents of the root directory of the C:
drive.
$ cat 'C:\Users\Gabriel\test\files.txt'
If you installed vim or another text editor, you can also invoke it as usual to create a bash shell script. The following example will search for files with permissions set to 777 beginning at the directory given as parameter and will 1) print the file names to the screen, and 2) change the permissions to 644, and delete them if they are empty.
# vim fixperms.sh
Add the following content to file:
#!/bin/bash DIR=$1 echo "The permissions of the following files are being changed to 644: " find $DIR -type f -perm 777 -print -exec chmod 644 {} + echo "The following empty files are being removed: " find $DIR -type f -empty -print -empty -delete
Feel free to add to the above script other commands if you wish, then give it execute permissions and run it:
$ chmod +x fixperms.sh $ ./fixperms.sh .
Let’s see the script in action:
As you can see, we were able to run a bash shell script in Windows (using the GNU version of find command) with the help of Cygwin – and that was just an example.
Think for a minute. What other examples of classic Linux commands would you like to see? Feel free to give it a try, let us know how it goes, and don’t hesitate to ask us for help.
Summary
In this article we have explained how to install Cygwin, a Linux-like command line environment for Windows. As such, keep in mind that it is NOT a method to run native Linux applications in Windows, but you can compile applications using the source code if you want to do so.
If you find out that some of the commands you use more frequently are not available, restart the installation and search for the specific packages when you reach Step 4 (feel free to repeat this process as many times as needed). The number of packages available is amazing and the chances of not being able to find what you need are next to zero.
If you have had the chance to use Cygwin already, we would appreciate it if you can leave a comment using the form below to tell us about your experience. If not, we certainly hope we ignited a spark of interest with this article, and your feedback is highly appreciated as well.
how to install software like gsac, python using cygwin in windows
Please refer to Step 4. If the packages you want to install are not listed under the software categories, you may attempt to install them from the command line once Cygwin it’s installed. However, keep in mind that Cygwin may have some limitations in this regard. On a side note, if you want to have Python in Windows, just install it in Windows.
@Jeff,
Of course they do :) – Please note I never said Python and Ruby apps don’t run on Windows, but they are native of command-line environments :).
Python and ruby apps run just fine on Windows. So do Java apps, in general. Where you run into problems is when the applications are binaries, such a C C++ or FORTRAN or COBOL.
@Jeff,
Of course they do :) – Please note I never said Python and Ruby apps don’t run on Windows, but they are native of command-line environments :).