How to Use Cygwin: 13 Steps (with Pictures)

Table of contents:

How to Use Cygwin: 13 Steps (with Pictures)
How to Use Cygwin: 13 Steps (with Pictures)
Anonim

Cygwin is a free program that features a command line user interface that allows you to run commands and programs created for Linux and Unix systems within Windows. In other words, it recreates an environment in which you can run programs and commands for Linux and Unix systems on a Windows computer. If you are a user who has used Unix systems before, Cygwin will simplify the execution of commands and programs for this operating system within Windows. While it may seem very complex to use at first, with a little practice it will gradually become more familiar and intuitive.

Steps

Part 1 of 2: Install Cygwin

Use Cygwin Step 1
Use Cygwin Step 1

Step 1. Install Cygwin on your computer. Visit https://cygwin.com and click on the "Install Cygwin" link displayed on the left side of the page. This way you will have the possibility to download the file setup.exe and select the "Install from Internet" installation mode. Click on the "Next" button to continue.

Use Cygwin Step 2
Use Cygwin Step 2

Step 2. Choose installation settings

In most cases it is good to use the default installation directory which is "c: / cygwin \" and also use all the other configuration settings of the program.

Use Cygwin Step 3
Use Cygwin Step 3

Step 3. Configure the directory for temporary files

This is the folder where Cygwin will store all the packages you download while using the program. In this case you can select a directory of your choice.

Use Cygwin Step 4
Use Cygwin Step 4

Step 4. Download the installation files by choosing the "Direct Connection" option

You will be given a list of servers from which to download Cygwin installation data. You can choose to use the default link or, if the download speed doesn't suit you, you can choose to use one of the other servers available. Click on the "Next" button to continue.

Use Cygwin Step 5
Use Cygwin Step 5

Step 5. Choose the packages to install

You will be provided with a long list of packages which may be intimidating if this is your first time using Cygwin. In the latter scenario, it is best to rely on the default selection, so click on the "Next" button to continue. Wait for the progress bar, which indicates the Cygwin download and installation status, to be completely full. The time required for this step to complete should be a few minutes.

Use Cygwin Step 6
Use Cygwin Step 6

Step 6. Use Cygwin as if it were a Unix system

At first you will have to do some sort of customization of the work environment. For example you will need to create your user account and enter it in the "/ etc / password" file. Make sure you instruct the installation procedure to create a Cygwin icon directly on the Windows desktop. This way when you double click on that icon the Cygwin command shell will be displayed.

Use Cygwin Step 7
Use Cygwin Step 7

Step 7. Wait for a few lines of text to appear on the screen

This will only occur when Cygwin is first started. After the first initial phase of setup, you will be greeted by a command prompt similar to the following

username @ computer_name ~ $

green in classic Unix style. This is the interface you can use to execute the commands you want.

Use Cygwin Step 8
Use Cygwin Step 8

Step 8. Update the programs present in Cygwin

If you need to update existing programs within Cygwin or download new ones, return to the main page of the Cygwin website and click on the "Update" tab. The installation configuration settings that you already encountered while installing Cygwin will be displayed again.

Part 2 of 2: Using Cygwin: The Basics

Use Cygwin Step 9
Use Cygwin Step 9

Step 1. Search for a file

Some of Cygwin's basic commands are those intended for searching and comparing files. To locate a file within the system, type the following command:

$ find. -name FILE EXAMPLE

. This command allows you to view the list of all files that have the indicated name, regardless of whether it is made up of uppercase or lowercase letters.

Use Cygwin Step 10
Use Cygwin Step 10

Step 2. Search for a keyword within a file

If you need to locate a file that contains specific text, you will need to use the "grep" command. For example, if you want to have the list of all instances of the word "EXAMPLE" present in the file "EXAMPLE.txt", you will have to use the following command:

$ grep 'EXAMPLE' EXAMPLE.txt

. But remember that the "grep" command is case sensitive. If you want to find all instances of the word "EXAMPLE", regardless of how it is written, read on.

Use Cygwin Step 11
Use Cygwin Step 11

Step 3. Search for a word within a file regardless of how it is spelled

The command to use in this case is similar to the previous one, but with the addition of the parameter

-the

after the keyword

grep

. The complete command will then be:

$ grep -i 'EXAMPLE' EXAMPLE.txt

Use Cygwin Step 12
Use Cygwin Step 12

Step 4. Compare two files

If you need to compare two files, you can do it quickly and easily using the command

diff

. The syntax consists of the "diff" command followed by the name of the two files to compare:

diff EXAMPLE1.txt EXAMPLE2.txt

. The contents of the two files will be displayed, one after the other.

Use Cygwin Step 13
Use Cygwin Step 13

Step 5. Explore Cygwin's basic commands

Here is a table showing Cygwin's list of basic commands along with their Windows counterpart.

Action Windows Cygwin
listing directories dir ls
clean the command line window concrete clear
copy one or more files copy cp
move one or more files move mv
delete one or more files of the rm
create a directory md mkdir
delete a directory rd rm -rf
change the current working directory CD CD
view the current working directory cd, chdir pwd
perform a search find grep
concatenate two files cat cat
change the access permissions chmod chmod
display text as output echo echo

Recommended: