Working with Your Computer
In this module, we will learn to:
- navigate and manipulate your computer using the Terminal
- conceptualize your computer as a computing machine connected to other computing machines
1. Working with the Terminal
Throughout this tutorial, we will be spending a lot of time in Terminal/PowerShell as our primary way of talking to our computers. In order to do this, however, it is necessary to take some time to get comfortable working with the command line.
So let's walk through some basic commands while setting up our computer for the rest of the tutorial.
First, open Terminal/PowerShell and let's get a sense of where we are in the file structure of our computer.
Type pwd and press "Enter".
The command, which stands for "print working directory", tells you which directory you are in. Navigating the computer through the Terminal sometimes feels like tunneling, and pwd is very helpful for checking where you are at any given time. You should see something like:
if you're on a Mac or
Type ls and press "Enter".
This is another helpful command for orienting yourself. This command lists all the files in your current directory. If you need to see hidden files, type ls -a (Mac) or ls -Hidden (Windows).
You should see something like:
1 2 3 4 5
jeris-mbp:~ jeriwieringa$ ls Applications Dropbox Music Desktop Envs Pictures Documents Library Public Downloads Movies Sites
Now that we know where we are, we need to learn how to move around the different folders. This is done with cd or "change directory". If you just type cd, you will move back to the root of your user directory. To move forward, type:
and press Enter.
You can also move multiple directories at a time with:
This way you can dig down through your files. Go ahead and give it a try.
Type cd Documents and press Enter. Now type ls and press Enter.
You can also move backwards by typing cd ../. To move back multiple directories, type cd ../../../.
Go ahead and give that a try. After moving around, work your way back to the "Documents" folder.
Let's create a folder for our work today.
Type mkdir dhb_awesome and press Enter. Now type ls and you should see your "dhb_awesome" folder. Use cd to move into that folder.
Folders are great but it is also helpful to know how to make files. For that, we'll use a command called "touch" on OSX and "New-Item" on Windows.
If you're on a Mac, type:
and press Enter.
If you're on Windows, type:
New-Item -ItemType file my_first_script.py
and press Enter.
Run ls to see the file you just created.
To edit your new file in your text-editor, type:
on your Mac or
Start notepad++ my_first_script.py
on your Windows machine.
This should launch your default text editor. (For Mac users, if the file does not open in TextWrangler or your text editor, work with your coach to set your default editor.)
Type print "Hello World" into the text file and save. We will do something with that soon.
If you want to learn more commands–like how to remove, copy, or rename files–checkout the Scholars' Lab Command Line Bootcamp. But this is enough to start!
2. Terminology and Mapping the Computer
Now we're going to take a step back to think about the different layers of the computer that we will be working with and about how we move data from one process to another.
We will talk more about moving from the graphical interface to the terminal interface for communicating with our computers. Then we will talk about using APIs (or Application Programming Interfaces) for communicating between computers.