The data on your disk is organized into files and folders.
A program used to browse your files and folders is called a file browser.
We use folders to organize our files.
The folder "CS110" could be used to store files and folders for CS110.
Inside the CS110 folder you might have other folders like "Lab1" and "Project2", which contains files that are specific to just those labs and projects.
Every file and folder on your disk belongs to another folder.
Except for one: root
C:
/
A terminal is a program that gives us the ability to browse files and folders and run programs using only a text interface.
When you start the terminal, you will see a prompt
, such as the %
above.
You navigate in a terminal with commands instead of using the mouse like you would in a graphical file browser. Commands include:
cd
¶cd
stands for change directory.
You specify the path you want to change to, and that new path becomes the working directory.
cd
cd Documents
cd cs110
The cd
command by itself will change to your home directory.
pwd
¶pwd
stands for print working directory.
It prints the path to the current, or working, directory.
pwd
The graphical file browser (Finder, File Explorer) is working with the same files as your terminal.
Try using mkdir
to create a directory. Then look in your working directory with the graphical file browser. You will see it appear there, because you have one file system.
Every folder and file has a path that provides its unique location in your file system.
Paths that start with the root are called rooted or absolute paths.
C:\Users\zappala\Documents\syllabus.pdf
/Users/zappala/Documents/syllabus.pdf
Paths that start with the current directory are called relative paths.
If I am currently in /Users/zappala
, then Documents/syllabus.pdf
describes the file /Users/zappala/Documents/syllabus.pdf
cd
ls Documents
ls Documents/cs110
I can also refer to the current directory using .
.
So, if I am currently in /Users/zappala/Documents/cs110
, then ./syllabus.pdf
describes the file /Users/zappala/Documents/cs110/syllabus.pdf
.
cd
cd Documents/cs110
ls ./syllabus.pdf
Windows:
ls .\syllabus.pdf
I can refer to the parent directory directly using ..
cd # goes to home directory
cd Documents # goes into Documents directory
cd cs110 # goes into cs110 directory
cd .. # goes back up to Documents directory
You can chain these together:
cd # goes to home directory, /Users/zappala
cd Documents/cs110 # goes into /Users/zappala/Documents/cs110 directory
cd ../cs260 # goes into /Users/zappala/Documents/cs260 directory
cd ../.. # goes into /Users/zappala
Typing out paths and file names can be tedious.
Humans are also notorious for making typos.
Your terminal is eager to help you.
Start typing something. Press the tab key. What happens?
Press tab once to auto-complete whatever you are typing.
Sometimes, what you are typing is ambiguous (e.g. you typed cell
but there are files named cello-song.mp3
and cell-phone-plan.pdf
).
In these cases, depending on your terminal, you have some options:
A file is just a bunch of data (1's and 0's).
The file extension communicates to the OS how the data should be interpreted.
Is the data an image? .png, .gif, .jpg
Is the data a document? .docx, .pages
Is the data a PDF file? .pdf
The operating system (OS) is the software responsible for supervising all the pieces of your computer.
CPU, RAM, disk, keyboard, display, USB port, WiFi, speakers, etc.
For some of you this is Windows. For others this is Mac OS. You may have also heard of Linux—it's another operating system.
The CPU (Central Processing Unit) runs programs. Microsoft Word and Slack are examples of programs.
Since you are often running many programs at a time, and each program is composed of many tasks, the CPU is busy juggling many tasks simultaneously.
CS 224 will teach you more about how the CPU does its job of running a program.
Programs use data. For Microsoft Word, the data is a document you are editing. For Slack, it is all the messages everyone is exchanging.
All data can be represented as a sequence of 0s and 1s. We call a single 1 or 0 a bit.
We call a sequence of 8 0's and 1's a byte.
1 thousand bytes is a kilobyte. 1 million bytes is a megabyte. 1 billion bytes is a gigabyte.
Your disk stores data (1's and 0's) so you can use it later.
Data on your disk is still there after you restart your computer.
When the CPU needs data, the operating system copies it from the disk into RAM (Random Access Memory)
Data (1's and 0's) in RAM go away when you restart your computer.