ST: Command Line

What is the Command Line?

Most of use are accustomed to interacting with our operating system by moving around the mouse and clicking on images of folders, and choosing options from drop down menus. This interface is called the “Graphical User Interface” or GUI. But you can also interact with your operating system using text-commands the same way you work with R, Stata, or Python with text commands. The interface for interacting with your operating system using text commands is called “the command line”.

Well, actually, it has lots of names. Here I’ll call it the “command line”, but on a Mac, you will also heard it referred to as “the terminal”, “command prompt”, “UNIX”, “bash”, and “the shell”. On Windows, you may heard it referred to as “DOS”, “Command Prompt”, “PowerShell”. These are all basically the same.

Here’s the most important thing to know about the Command Line: it’s not as scary as it seems. In fact, the command line is an incredibly simple tool that is mostly just used to move from folder to folder in your operating system and either open files or execute other programs.

Intro to Command Line

How the command line works depends on your operating system, so below resources are split to OSX resources and Windows resources.

Mac Users / Linux Users / UNIX Users

First, I’m gonna let you in on a little secret: OSX, Linux, and Unix are actually all built on the same fundamental operating system (UNIX), and so when you’re working through the command line, they all behave the same. In fact, this “family” is often referred to as “POSIX”.

Quick, great gentle intro It gets a little lost around minute 10, but the first part is really all you need to know.

The general syntax for command line commands is:

[name of program or command] [space] [options or arguments passed to program]

That’s it. So for example, you’ve probably seen in your tutorials people writing a python file, then saving it, and running it by openning Terminal, navigating to the folder that file is in, and typing:


They’re just launching Python (first word), and telling it to run the file

Windows Users

Here’s a great tutorial, but only read the sections “What is Command Prompt?” and “Working with Files and Directories”. The stuff on Java doesn’t really matter.