Getting Started with Cygwin
Cygwin is a version of the Linux bash shell for Windows. It provides a great way to automatically script operations, and if you’re a fan of the command line then its a great way to navigate your system. However the default Cygwin installation is not very friendly, and many features that you’d expect from the Linux command line are not configured by default. The aim of this guide is to describe the actions I take when installing Cygwin from scratch.
Part One – Downloading and Installing Cygwin
Installing Cygwin is very easy – simply visit the Cygwin project page and click on the Install Cygwin Now link. Download the setup.exe file to your computer and run it. The setup is a simple wizard interface, which will take you step by step through the process, including selecting the packages you want included. I usually use the defaults, adding only a couple:
vim– the UNIX text editor of my choice. emacs and nano are also available (along with many others)lftp– a powerfull command line FTP client, used for scripting FTP operations.openssh– the Linux SSH clientopenssl– command line SSL, great for doing simple encryption tasks
You can also select to install everything, which will give you a pretty complete Linux system, but there are a lot of packages and they take ages to download. Most of them you’re unlikely to use.

You can come back and run setup.exe again later if you find you want to add or remove packages. It acts as a pretty comprehensive package management system for your Cygwin installation – it can be used to update your system with the latest binaries too.
Part Two – Starting Up
When you first start Cygwin, you might get the error:
Your group is currently "mkpasswd". This indicates that the /etc/passwd (and possibly /etc/group) files should be rebuilt. See the man pages for mkpasswd and mkgroup then, for example, run mkpasswd -l [-d] > /etc/passwd mkgroup -l [-d] > /etc/group Note that the -d switch is necessary for domain users.
This means that Cygwin is not aware of your current user setup. Run the commands specified, using the -d switch if your computer is a member of a Windows domain. These commands will create /etc/passwd and /etc/group files that tell Cygwin about your user setup. Exit Cygwin and start it up again.
Part Three – Setting Your Home Directory
When you restart Cygwin you’ll probably find that your home directory is now your Windows home directory. This might be what you want, but I always prefer to move it. Moving it has the following advantages:
- Cygwin won’t get in the way of your Windows setup by adding configuration files (starting with .) to your nicely organised Windows home folders.
- You can create symbolic links to My Pictures, My Music, My Videos etc, rather than having to type “My\ Pictures” every time.
To change your home directory, edit the /etc/passwd file in your favourite text editor. If you installed Cygwin in C:\Cygwin then this file will be here:
c:\Cygwin\etc\passwd
The passwd file is a list of users registered within Cygwin, with the following fields:
username:password:uid:gid:user info:home directory:shell
Find your Windows user and change the home directory to your preferred folder. I usually just use /home. You’ll need to create this folder in c:\Cygwin\home too. You should find that when you restart Cygwin your home directory is the one you specified.
Part Four – A Better Command Line
The default Cygwin command line console is pretty naff. I much prefer to use PuttyCyg, which is a patched version of the PuTTY telnet/ssh client.
To install PuttyCyg, download it from the project downloads page, and unzip it to your Cygwin directory. When you run it, simply select Cygterm as your session type and enter “-” as your host name. Clicking Open will open up Cygwin.
There are a few minor tweaks I like to select when running PuttyCyg, which I save into a session called Cygwin:
- Window > Behaviour > System Menu Appears on ALT-Space
- Window > Behaviour > Full Screen on ALT-Enter

You can then create a Windows shortcut to the following command to run that saved session every time:
C:\cygwin\putty.exe -load Cygwin
Part Five – Getting Your Keyboard Working
If you have a bit of a play around with the Cygwin command line you might find that some things don’t work quite as you’d expect them to:
- There’s no way to paste into the PuttyCyg window (without using the mouse)
HomeandEndkeys might not work properly- The
Deletekey might not work as it’s supposed to - Auto-completion using the
Tabkey is case sensitive – fine in UNIX but hard to use with Windows
To fix those issues (and a few more) create a file called .inputrc in your home directory. The file should contain the following:
"\e[1~": beginning-of-line "\e[7~": beginning-of-line "\e[4~": end-of-line "\e[8~": end-of-line "\e[3~": delete-char "\e[2~": paste-from-clipboard set completion-ignore-case On set meta-flag On set convert-meta Off set output-meta On set horizontal-scroll-mode On
After restarting Cygwin you should find that the Home, End and Delete keys work nicely, and you can paste the contents of the Windows clipboard using Insert. Auto-completion will be case insensitive.
Part Six - Getting VIM Working
As per any Linux installation, VIM without a .vimrc file defaults to the default behaviour of vi, which is fairly unfriendly. Also some of the key mapping doesn't work beautifully in Cygwin. The following is my .vimrc file (to be placed in your home directory):
set expandtab set shiftwidth=3 set tabstop=4 set backspace=indent,eol,start set scrolloff=1 set whichwrap=b,h,l,<,>,~,[,] nnoremapdh set background=light set hidden set showcmd set ttyfast set encoding=utf-8 set ignorecase set smartcase set incsearch set hlsearch syntax on colorscheme torte
Part Seven – Setting Up Some Folders
Your Windows drives are all stored under a virtual folder called /cygdrive/ in Cygwin. So to access your C:\ drive you would type:
cd /cygdrive/c
This is probably the best way they could have set this up, but its not exactly easy-access when you want to quickly get around your system. To solve this I set up a few symbolic links. You only need to run these commands once:
ln -s /cygdrive/c /c ln -s /cygdrive/c/Documents\ and\ Settings/Your Windows Username/My\ Documents/ ~/docs
You should now find that you can access your C:\ drive using cd /c and your documents folder by using cd ~/docs. Obviously you can set up as many of these symbolic links as you’d like – I usually set up links to My Pictures (~/pics), My Videos (~/videos) and My Music (~/music).
Part Eight – Setting Up Some Shortcuts
Personally I like to set up some shortcuts in my ~/.profile file so that I can launch applications quickly:
alias cs='cygstart' alias firefox='cygstart firefox' alias ff='cygstart firefox' alias notepad='cygstart notepad++' alias navicat='cygstart /c/Program\ Files/PremiumSoft/Navicat\ 8.0\ MySQL/navicat.exe' alias opera='cygstart /c/Program\ Files/Opera/opera.exe' alias iexplore='cygstart /c/Program\ Files/Internet\ Explorer/iexplore.exe' alias gimp='cygstart /c/Program\ Files/GIMP-2.0/bin/gimp-2.6.exe' alias filezilla='cygstart /c/Program\ Files/FileZilla\ FTP\ Client/filezilla.exe' alias cygwin='cygstart /c/cygwin/cygwin.lnk'
Note that the commands above won’t work unless you’ve implemented my /c symbolic link above – if you haven’t done that then you’ll need to use /cygdrive/c instead. Also note that all of the commands use cygstart – cygstart is a great little command that basically launches whatever you want using Windows. So if you’re in any folder and type:
cygstart .
… then it will open the current folder in Windows Explorer. If you type:
cygstart somedoc.doc
… then somedoc.doc will open in Microsoft Office or Open Office. In my aliases above I shorten cygstart to cs for quick access.
Part Nine – What Next?

After carrying out all of those steps you should have a nice, neat and easy to use Cygwin installation. Next its down to you to leverage the power of the UNIX command line and give Windows a bit of kick.


[...] writing my previous post on Getting Started with Cygwin I was slightly perturbed to discover that my brand-new Cygwin installation was running pretty [...]
Thanks so much. You have helped me solve a problem that has been slowing me down for the last two weeks since I have started using Cygwin exclusively at work for command line tasks.
A great primer to getting cygwin more user friendly. Thanks.