Skip to content
Related Articles

Related Articles

Improve Article
Save Article
Like Article

How to Use Linux Commands in Windows with Cygwin

  • Last Updated : 11 Oct, 2021

Cygwin is a collection of tools that provide a Linux Operating System’s terminal look, feel, and some of its basic functionality for users of Windows OS who want to have a go over the basic commands of Linux without worrying about installing a Linux OS.

To use this tool, first of all, we need to download Cygwin setup depending on the version of Windows i.e either 32 bit or 64bit.

Installation

Step 1: Launch the Cygwin installation setup and press Next

Step 2: Choose “Install from Internet” and press Next



Step 3: Select the root install directory where you want to install it and choose whether to install it for yourself or for all users and press Next

Step 4: Select a directory where you want to store installation files downloaded by this installation setup and press Next

Step 5: Select the way you want installation setup to connect to the internet and press Next

Step 6: Choose a download site from available download sites and press Next



Step 7: Select packages to install depending upon your needs and press Next

Step 8: Review and Confirm changes

Step 9: Packages will take some time to get downloaded

Step 10: Installation completes and Cygwin is ready to be explored now, press Next

Add Cygwin Path to Windows Environment Variable

To make Cygwin work in your normal command prompt, we need to add Cygwin to Windows Environment Variables as follow:-



Step 1: In the search bar type “Advanced System Settings” and click on the matching field

Step 2: Click on the Environment Variable button on the bottom right side 

Step 3: Under the system variable tab, select the Path variable and press OK

Step 4: In the installation phase of Cygwin, i.e in Step 3 where the root install directory was chosen for Cygwin installation, go to that location and inside it, copy the location of the bin folder.

copy Location

Step 5: Paste it in the environment variable section which was opened after the completion of Step 3 and press OK

Setting up of Environment variables is completed, we can now run our Linux commands in command prompt



Usage

To use Linux commands in Windows with Cygwin, we can now either open Cygwin or command prompt and all we have to do is to type the command into the terminal/prompt and press Enter, as follows :

Example 1: pwd command in command prompt

pwd 

Example 2: ls command in command prompt

ls 

Example 3: echo command in command prompt

echo "your text"

There might come some situation when you want to execute some non-basic commands of Linux in Cygwin whose packages are not installed during the installation process, as follows :

Example 1: nano command in command prompt

nano file_name.txt 

This happens because of the reason that the installed package of Cygwin doesn’t contain the functionality for these commands. To use these commands you have to select packages in the Installation Phase (Step 7) containing the functionality for this command.

My Personal Notes arrow_drop_up
Recommended Articles
Page :