Cygwin Cheat Sheet

The Cygwin Console (i.e. the Cygwin Bash Shell) is where you will execute all your HTK/Julius commands and scripts, and your VoxForge scripts.  It provides a Linux-like environment to execute your commands

Starting Cygwin 

Open your Cygwin Console by clicking:

    Start>All Programs>Cygwin>Cygwin Bash Shell. 

Working with Directories

When you start a Cygwin Console, you are automatically sent to your Cygwin home directory - which usually corresponds to your Windows username.  All Windows users on your system should have a home directory with a Windows path of:

        c:\cygwin\home\[Windows Username]

To find out what your home directory name is type the 'pwd' (i.e. print working directory) command  in a newly opened Cygwin Console.  In this example my home directory is called 'Administrator':

 $pwd
 /home/Administrator

 

Note on Cygwin directories

  • Cywin uses the Linux standard approach to naming directory paths - which uses the forward slash "/" to separate directories, rather than the Windows approach with uses the backward slash "\" to separate directories.
  • Cygwin does not use the [drive letter + ":"] notation to denote your root directory on a hard disk - i.e. there is no "c:" drive in Cygwin.  The Cygwin root directory is denoted by a single forward slash "/".

Directory Structure

Cygwin attempts to duplicate the directory structure of a Linux System within the "c:\cygwin" folder:

 Windows location
 Cygwin Console
 c:\cygwin\bin /bin
 c:\cygwin\etc /etc
 c:\cygwin\home /home
 c:\cygwin\home\administrator /home/administrator
 c:\cygwin\lib /lib
 c:\cygwin\tmp /tmp
 c:\cygwin\usr
 /usr
 c:\cygwin\var /var
 c:\cygwin /

 

Creating Files

When creating directories and files in your home directory in Cygwin, remember that you can use Windows Explorer to create a file, and Windows Wordpad to edit it (see below for the Cygwin commands to do this).  For example, if you need to create a file in the following Cygwin directory:

/home/[your home directory]/voxforge/manual,

then start Windows Explorer, go to this directory

c:\cygwin\home\[your home directory\voxforge\manual

and click 'File>New>Text Document' in Windows Explorer to create an empty file.  Then use Windows Wordpad to edit it, by doubling-clicking the new file, and selecting WordPad from the 'Open With ...' selection window.

Note: If you create a file directly in WordPad, when you save it WordPad will try to append a '.txt' or '.rtf' suffix to your file name.

Cutting and Pasting Content from Windows to Cygwin

from the Windows application: 

  • highlight the text to be copied;
  • right-click and select copy from right-click menu (or hit ctrl-c key combination); 

go to Cygwin window:

  • right-click Cygwin window header
  • select Edit>Paste from the right-click menu

Extracting Gzipped Tar files in Windows

The 7-Zip program can unzip and untar Linux gzipped tar files from Windows Explorer.  Once installed, you simply right-click the file you want to unzip and/or untar in Windows Explorer, and select 7-Zip from the right-click menu.  If your file is gzipped and tarred, you need to execute the 7-Zip extract twice: first on the .tgz file, and then again on the generated .tar file.

It is Open Source and licenced under LGPL.  It can be obtained at:

http://www.7-zip.org/ 

You can also use the Cywin tar command (see below) 

Common Cygwin commands:

Working with Files

cp <filename> <new filename>
    copy - Make a copy of a file

cp -R <directory> <new directory>

    Make a copy of a directory

mv <filename> <new filename>

    move - Move or rename a file

rm <filename>
    remove - Delete a file

Working with Directories

cd <directory>
    change directory - Change to the directory specified

ls
    List - Lists the files in the current directory


ls -l

    Lists the files and their attributes

mkdir <new directory name>
    make directory - Create a new directory

pwd
    Path of working directory - tells you what directory you are in

 

Archiving/Extracting Files and Directories

 tar -zcvf  <filename> <directory>  # create  gzipped  tar  archive  of  <directory>

  • -z - filter the archive through gzip
  • -c -  create a new archive
  • -v - verbosely list files processed
  • -f - use archive file

 tar -xvzf  <filename>     # extract tarred, gzipped <filename> in current directory

  • -x - extract files from an archive
  • -v - verbosely list files processed
  • -z - filter the archive through gzip
  • -f - use archive file

Working with File Permissions:

chmod u+x <filename>
   changes permission of the named file to executable
.

  • u - user, (this means you)
  • + - adds permissions
  • x - executable rights

You can get further details on any commands in Cygwin by using the 'info' or the 'man' command.  These provide essentially the same information, but with slightly different formatting.  To obtain detailed information on the 'mv' for example, you would type one of the following:

$info mv

$man mv 

to exit info or man, type the letter 'q' at the ":" prompt. 

 

Comments

By gbs - 5/5/2016

By rupelto - 3/19/2014 Thank you for sharing your knowledge , i feel less stressed.

By dheeraj - 4/11/2013 - 1 Replies i want to change my command from $ to # command...is it possible just like shell scripting in linux based terminals

By Kostas V - 3/29/2013 - 1 Replies Hello I want to ask a question. I have this coomand:

By Curtis S. - 9/13/2012 - 1 Replies Thank you for your very approachable list of basic commands. It would be extremely helpful if the Cygwin community could maintain something similar with all of the major commands for packages installed by default. Coming from the Windows side, the major reason Unix isn't making more headway is because of a lack of simpler, clearer instructions on using the OS. Windows users are not stupid, we just come from a very different type of computing. Once we know our way around, trust me when I say that we will start pushing to find out what Cygwin's true capabilities are. We like to know what our system's capabilities are to maximize performance.

By Viking - 8/22/2012 How can I list the paths to the hard drives?

By Radu - 10/20/2008 - 9 Replies There is an easier way to copy+paste in Cygwin (found it just today, after 3 months of torment).