Hi, I'm Boopathi Rajaa.

Hacker, Dancer, Biker, Adventurist

Shell commands in Windows cmd

It is possible to use a few of the shell commands in windows. Though there is this program called windows power shell, most of us are not familiar with batch scripting. So we could use Cygwin , a project that has windows executable files performing the operations of the shell.

Cygwin.bat :

There is not much to explain about this file. Just go through its source code and you will pretty much understand those 5 lines of code. It just sets the working directory to <Cygwin_installation_directory>. In my case it is C:\Cygwin\bin.

This directory contains the shell command executable files like cat.exe, chmod.exe, chown.exe, cp.exe, diff.exe, find.exe, su.exe, touch.exe, less.exe, ls.exe, which.exe, who.exe, etc.

Mission :

Now we have to add this directory to the PATH environment variable. In windows, there are two Path variables – User Path and the System Path. We will add this to the system PATH variable. When you do a echo %PATH% in command prompt, you will see a concatenated list of System Path and User Path.

Instructions :

  1. Open System Properties

    • Right Click My Computer –> Properties –> Advanced System Settings.
    • Control Panel –> System –> Advanced System Settings.
  2. Select Advanced tab.

  3. Click Environment Variables button.

  4. Under System Variables fieldset, scroll down to " Path " under variables column, and select this entry.

  5. Click Edit, and in this Variable Value textbox, append the <Cygwin_installation_dir> with a semi-colon as the separator.

    • Variable Value : foo;bar;C:\Cygwin\bin
  6. Select OK consecutively for all the dialog boxes that you opened – confirming changes.

Sample :

Now you can use all the exe files in the Cygwin_installation_dir as a command in command prompt.

C:/>ls -lta | grep cygwin
drwxr-xr-x+ 1 Boopathi Rajaa root 4096 Feb 24 00:14 cygwin