STAT207 - Data Science Exploration
Fall 2023 - Ellison

Using Command Line Interface


General Command Line

If you think about how you usually use a computer, you probably navigate to a file by clicking on directories and open a program or file by double clicking on them. When you are programming a computer, you often need to run programs and send them options, called arguments, which is nearly impossible to do with only a click.

Because of this, every operating system contains a Command Line Interface (CLI) that lets you interact with your computer using a keyboard. You can do everything you already do on a computer via the command line, but you can also do a whole lot more!


Opening Command Line

Windows

  1. Press [Windows Key] to bring up the “Windows menu”
  2. Type: cmd (or anaconda after you installed miniconda)
  3. Press [Enter]
  4. A black box titled “Command Prompt” will open

Mac OS X

  1. Press [Command]+[Space] to open Spotlight, or open up Spotlight or App Launcher
  2. Type: Terminal
  3. Press [Enter]
  4. A white box titled “Terminal” will open

Command Prompt

Both command line tools start every line with a prompt that shows the current working directory of the command line tool. By default, both Windows and Mac starts you off in the base folder for your user account. The syntax varies only slightly between the two (assuming a user named Karle), so the initial prompt should be one of the following:

  • Windows: C:\Users\Karle\
  • OS X: Karle-MacBook-Pro:~ Karle$

Current Working Directory

When using the command line, you are always “inside” of one specific folder (much like when you double-click a folder you see the contents of everything in that folder and only that folder). The current folder that your command line tool is in is referred to as the current working directory.

In Data Science Discovery, we recommend that you work within a directory called stat207 on your desktop. (If you choose to have your directory on the desktop, go to your go to your desktop screen and make a folder how you normally do and call it stat207 if you hvaen't already.)

In order to navigate to that directory IN THE COMMAND LINE, we need to first navigate to your Desktop (in the command line) and then navigate to the stat207 directory (in the command line). Both of these things can be done with the cd command (cd for “change directory”):

cd Desktop
cd stat207

You can visually verify that you are now in your Stat 207 directory by looking at the prompt:

  • Windows: Open a file explorer and go to: C:\Users\Wade\Desktop\stat207
  • OS X: Wades-MacBook-Pro:~ stat207$

Useful Command: Listing Files

When using a command line tool, you often want to know what files are in your current working directory. To list all files in the current directory:

  • Windows: dir
  • OS X: ls

Useful Command: Moving Up a Directory

In addition to moving “forward” or “deeper” into your directories, the special cd .. will change your directory “up” one directory.

  • Moves into stat207 from your Desktop (one level deeper): cd stat207
  • Moves back to your Desktop from stat207 (one level shallower): cd ..