How to use Unix/Linux commands at the Windows command prompt


A lot of us who use Linux at work/school or have always grown up using unix commands for years and more often than not, there might have been instances where a ls command comes more naturally than the dir command at the command prompt in Windows. For the most part, a lot of us work around this drawback using the excellent tool: Cygwin. Cygwin is available for windows users here.The Cygwin tools are ports of the popular GNU development tools for Microsoft Windows. They run thanks to the Cygwin library which provides the UNIX system calls and environment these programs expect.

With these tools installed, it is possible to write Win32 console or GUI applications that make use of the standard Microsoft Win32 API and/or the Cygwin API. As a result, it is possible to easily port many significant Unix programs without the need for extensive changes to the source code. This includes configuring and building most of the available GNU software . Even if the development tools are of little to no use to you, you may have interest in the many standard Unix utilities provided with the package. They can be used both from the bash shell (provided) or from the standard Windows command shell.

While Cygwin would be an obvious choice for many Unix/Linux power users, there is an excellent and a much simpler alternative to using Cygwin. In this article, we will show you how to run your Unix commands right in the windows command prompt.

For this, we will be using CoreUtils. CoreUtils is available through Sourceforge and is available for download here. If you look in here, there are a number of GNUWin32 packages available, the one we would be using is the CoreUtils package. CoreUtils is a collection of basic file, shell and text manipulation utilities of the GNU operating system. These are the core utilities which are expected to exist on every OS. And when I talk about File utilities, they include chgrp, chmod, cp, dd, du, ln, ls, mkdir, mv, rm, touch, vdir among others. A sample of the text utilities include cat, cksum, cut, join, md5sum, shasum, sort, split etc. The shell root commands include echo, chroot, hostname, nice, pathchk, tty, who, whoami and yes su. So it is pretty much the whole nine yards here… The direct link for download of the CoreUtils package available through SourceForge is available here.

Once installed, you will need to add the path to the utilities to your PATH environment variable. Follow the steps below to achieve this

1. Click on Start –> Run and enter sysdm.cpl to bring up the system properties Dialog

2. Click on the Advanced tab –> Environment variables button Path to environment variable

3. In the System Variables pane, scroll down to Path and then click on edit.

4. Under Edit System Variable, in the variable value, at the end of the line , type the following including the semicolon which separates the individual elements in the path variable. ;C:\Program Files\GnuWin32\bin

env variable properties

Congratulations !! You have now added the GNUWin directory to your path and Unix commands can now be executed directly from the command line and run natively on the Win32 command prompt without the need for any emulation layer as shown below using the example of dir vs ls

command prompt comparing dir vs lsDownloads and Sources

1. Download CYGWIN

2. Download CoreUtils


If you liked this article, click here to buy me a beer!

  • Pingback: Designer Learns to Code: Pt. 1 (Struggles) | The Nostalgia Machine()

  • NetTron

    Duc delete 7-zip or open it with WINRAR 

  • Sandun89

    Thanks….this is help me to work with Linux without install it 

  • gusch

    nice! :-)

  • lakshminarayana

    Hi sir,thanks a lot for your article, sir i have a doubt is it working for all windows operating systems.plz give me the reply

  • dora

    really nice…thanx a lot…

  • Venkat Mantirraju

    Thanks a lot. Your instructions are neat and clear.

  • rinku

    Hello bhai mein punjab se hoon tera kaam bahut …………………………………… Super mind blowing
    thanx man really thanx
    i love linux but due to lack of gui of linux i use window from last mounth i used linux since 6 years but i really do not know that how can i run linux commands in window xp
    Thanx man
    Rinku from punjab

  • lol768

    IMPORTANT – 64 bit users

    You must change the path to C:\Program Files (x86)\GnuWin32\bin instead of C:\Program Files\GnuWin32\bin

  • khwopa

    i really doubt all command of linux run or not
    example whois domain don’t work
    and some other also
    is there internal and external command to run or not run?

  • khwopa

    Thank you 100 time

  • Sivanesan

    I want the Linux command

  • sanjay

    thanks a lot friends

  • Mehdi

    I am going to add more commands to this…like ssh and sshfs. Please help me.

  • Tensigh

    Worked great, thanks for the article and links.

    vi and clear aren’t listed in coreutilities. I would imagine there’s a GNU version of vi available for Windows, though why would you want it? Ugh.

  • Pingback: Unix/Linux Commands Under Windows Command Prompt with CoreUtils » Quaint by Design()

  • yashwanth

    its working, but not all the cmds.
    clear,vi editor is not working.
    anyways great attempt,
    thanks a lot

  • hector

    nice tip! very cool

  • SR

    Thanks a lot.. Simply superb

  • stupid_students

    I want run c# commands in Eclipse.Please help.

  • Vishal

    Hi can we add more commands to this…like i m unable to run wget command on windows….pls help me out…:))

  • matelot

    damn stupid comments above….

  • kavitha

    i need how to use a linux commands in windows

  • Zalam

    Dear Sir
    I read your article it is quite interseting and have an innovative move of having linux command under Linux.
    Dear Sir I have wine package installed under my Linux Box.It has a sub package winelib which provide the user with compiling a win32 application under Linux and is ran as native Linux executable. I want to execute a Linux command in a win32 application. I have the environment for compiling a win32 application but I don’t have a win32 application that a Linux command in it. If you may please help me How I can use Linux command in a win32 application I’ll be greatefull if you may help me in this

  • Pingback: Litany Against Fear » Blog Archive » Pimping the Windows Command Line()

  • anonymous

    In the command prompt, is there a way to unzip/ open winzip files if you dont have winzip?

  • Pingback: AskStudent » Blog Archive » Microsoft releases Windows PowerShell, a powerful replacement for cmd.exe()