The Command Line on Windows / Installing Bash

As dicussed in Command Line Basics, there are actually several programs available that allow users to interact with their operating system via text commands instead of using their mouse to click on icons. On this site, we’ll focus on learning bash, because it’s so ubiquitous in the data science space. Why? Mostly because it is the default command line tool for Linux operating systems, and while you may not know it, most of the computers you interact with on a daily basis run Linux. Your personal computer may be a mac (which also uses bash by default) or a windows computer, but the computers that run nearly every website you visit, manage your email, run those ticket kiosk you see at the airport, etc. are almost all running on Linux. Moreover, if your data science career ever requires you to use computers in the cloud (amazon cloud services, or just an extra powerful server you company or university has for really serious computational work), it will run Linux. So there’s a lot of good reasons to learn bash.

But: bash is not the default on windows, so on this page, I’ll show you how to set up a system that lets you work with bash on your windows computer. Note that because bash is not the default windows tool, there will be a few little wrinkles in how this is done, and it will never work quite as seamlessly as the default windows command line tools (PowerShell and CMD).

If you are a passionate windows user or someone who plans to only use windows, you are probably better off learning to use the default windows command line tools!

Install Cmder

To get a good bash interface in windows, we just need to install Cmder!. Make sure to select the Full Install (or you won’t get Bash). Note this will also install git, which we discuss elsewhere on this site.

I recommend unzipping the zipped Cmder file you download into your main User folder (so I unzipped into C:\Users\Nick). DON’T try and put it in ProgramFiles.

Once installed, you’ll have a new program called Cmder available! By default, Cmder is a kinda of hybrid interface that lets you use most commands people use in bash and the commands people use when working with the default Windows command line tool (CMD). This is nice for people with some windows command line experience, but it does mean that Cmder doesn’t quite work like bash.

With that in mind, we want to set Cmder to default to pure bash mode by clicking on Settings (the three horizontal bars on the bottom right), then changing the “startup task” to {bash::bash as Admin} (see pic below).

selectbash

Create .bash_profile File

As we’ll discuss in our command line exercises, the way you control settings in your Bash session is with a file called .bash_profile or .bashrc. Cmder won’t create this automatically, though, so we’ll create an empty file now for later use.

To make this file, in a new Bash session, run the following commands:

cd ~
touch .bash_profile

That’s it for now!