π£οΈ Week 01 - Set up your computer and meet the Terminal
Lab Roadmap (90 min)
Welcome to the first lab session of the course! When you come to the lab, make sure you have your laptop with you. You will need it to complete the lab exercises.
Our main objective today is to get you all set up with the tools you will need for the course. If you have done the set-up already, that is awesome! You can practice with the Terminal β something you will have learned about in the ποΈ Week 01 lecture.
π₯ Learning Objectives
Your progress will depend on whether you followed the π W01 Lab Preparation steps or not:
By the end of this session, you will be able to:
- Identify the βTerminalβ app on your computer
- Open a
bash
terminal - Interact with the
bash
terminal - Create and edit plain text files using the
bash
terminal
It is OK! Just reserve some time to practice with the terminal before the next lecture. You can ask questions on Slack at any time if you get stuck (#help-labs
channel or #help-installation
).
By the end of this session, you will be able to:
- If on Windows, install WSL2 and Ubuntu
- Install
bash
on your computer - Practice how to search online for solutions to common installation problems
- (time pending) Learn the basics of the
bash
terminal
π Lab Tasks
Here are the instructions for this lab:
π€ Part I: Introductions (20 min)
π§π»βπ« TEACHING MOMENT: Your chance to get to know your classmates and instructors.
βοΈ Part II: Setup (20-70 min)
Assuming you can install everything without any issues, this part should take you about 20 minutes. Then, you can move on to Part III.
However, it is VERY common for anyone (not just students) to encounter issues when installing software. If you spend the entire lab troubleshooting, this is absolutely normal! You are still learning quite a lot, trust us! Each computer is different, you might get a strange error message when following steps and even instructors might struggle to understand what is going on. This is your opportunity to learn how to effectively search for solutions online and ask for help on Slack.
π― ACTION POINTS
- Complete Step 1: Install the Bash Terminal on the π Getting Ready page.
Your class teacher will be going around, in between TEACHING MOMENTS, to help you with any issues you might have. If you are still stuck after the lab, ask for help on the #help-labs
channel on Slack.
π Part III: The terminal (60 min)
π§π»βπ« TEACHING MOMENT: Your class teacher will demonstrate how to open the terminal app and how to interact with it.
Step 1: Create a plain text file (10 min)
Click here to see the π― ACTION POINTS
Windows users
-
Hello, world! I am taking DS105A, and this is my first plain text file.
macOS users
-
Hello, world! I am taking DS105A, and this is my first plain text file.
Step 2: Locating yourself (20 min)
Click here to see the π― ACTION POINTS
Can you locate the hello.txt
file you just created using the command line? We will follow the instructions below step by step together while answering whatever questions you might encounter along the way.
Open the bash shell using the instructions from Step 1 above
Type
pwd
and hit ENTER:pwd
You should get a string of text indicating the full path of where you are inside the terminal. Remember the hierarchy of directories we discussed in the lecture?
Are you currently in your
$HOME
directory? To find out where your home directory is, use the following command:echo $HOME
Are there any files/sub-directories in your current directory? Use
ls
to investigate:ls
or
ls .
Are there any hidden files?
ls -a
Now, letβs explore what is above your current directory:
ls ..
Do you get what the different dots
.
and..
mean 1?Now, more than just look at the parent directory, letβs move there:
cd ..
Then, use the same
ls
commands you explored above. Did you notice anything different now?Letβs force
ls
to print the same information in a different format. Try the following command:ls . -lth
What does the
-l
,-t
and-h
arguments mean? You can find out by looking at thels
manual:man ls
Use the arrow keys on your keyboard to scroll up and down the manual. Type the character
q
when you are done browsing.Now, use what you have learned and go to the directory where the
hello.txt
file is. Hint: if you get stuck, trypwd
again and compare the output you get now to the one you got the first time you used this command.
For your future research, if you see β$β sign at the beginning of the code snippets, it means you are in a system shell and should type your commands in the shell.
$ pwd
Step 3: Wandering away from $HOME
(20 min)
Click here to see the π― ACTION POINTS
Now, given what we practised, try to follow the steps below (help from colleagues is fine) and take note of your answers to the questions.
We will go over the solutions once everyone has finished this step.
Go to the root of the filesystem:
cd /
What do you see with
ls
? What does it mean?Walk around freely up and down the directories and sub-directories you encounter. Check the links on π Week 01 Appendix - Linux and the Terminal page to understand where you are navigating.
Which directory(-ies) under
/
were you not allowed to enter? Why?What is the difference between the
/root
directory and the root filesystem/
?Go back
$HOME
Step 4: Creating and editing files and directories (20 min)
Click here to see the π― ACTION POINTS
Go to your
$HOME
directory or a folder of your choice. Then, create and enter a directory; letβs call it DS105L:cd $HOME mkdir DS105L cd DS105L
Create a text file and call it
README.txt
:touch README.txt
Now, using Windows Explorer or Finder, open the directory where you created the
README.txt
file. You should see an empty file.Using the text editor of your choice, write something to the file (your name, a verse, a sentence, whatever comes to mind) and save it.
Now, go back to the terminal and use
cat
to print the contents of the file:cat README.txt
Now close the terminal and open it again. Can you still see the file you created? If not, why?
Footnotes
See the answer to this question on Stackoverflow: βWhat is double dot(..) and single dot(.) in Linux?ββ©οΈ