πŸ›£οΈ Week 01 - Set up your computer and meet the Terminal

Lab Roadmap (90 min)

Author
Published

29 September 2023

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

  1. 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 logo Windows users

  • Hello, world! I am taking DS105A, and this is my first plain text file.
Apple logo 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.

  1. Open the bash shell using the instructions from Step 1 above

  2. 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?

  3. Are you currently in your $HOME directory? To find out where your home directory is, use the following command:

     echo $HOME
  4. Are there any files/sub-directories in your current directory? Use ls to investigate:

     ls

    or

     ls .
  5. Are there any hidden files?

     ls -a
  6. Now, let’s explore what is above your current directory:

     ls ..
  7. Do you get what the different dots . and .. mean 1?

  8. 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?

  9. 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 the ls 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.

  10. Now, use what you have learned and go to the directory where the hello.txt file is. Hint: if you get stuck, try pwd 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.

  1. Go to the root of the filesystem:

     cd /
  2. What do you see with ls? What does it mean?

  3. 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.

  4. Which directory(-ies) under / were you not allowed to enter? Why?

  5. What is the difference between the /root directory and the root filesystem /?

  6. Go back $HOME

Step 4: Creating and editing files and directories (20 min)

Click here to see the 🎯 ACTION POINTS

  1. 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
  2. Create a text file and call it README.txt:

     touch README.txt
  3. Now, using Windows Explorer or Finder, open the directory where you created the README.txt file. You should see an empty file.

  4. 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.

  5. Now, go back to the terminal and use cat to print the contents of the file:

    cat README.txt
  6. Now close the terminal and open it again. Can you still see the file you created? If not, why?

Footnotes

  1. See the answer to this question on Stackoverflow: β€œWhat is double dot(..) and single dot(.) in Linux?β€β†©οΈŽ