Just like last lab, you will start this lab by creating a GitHub repository by clicking on the link on the home page of this lab.
Go to github.com and navigate to your list of repositories. Once the lab 2 repository is created, you’ll need to use git clone to copy the files to this computer. Just like last time, open the terminal and type
git clone XXXX
where XXXX is the repository address that you copy from the CODE button on the GitHub page for the repository.
In this part of the warmup, we are going to use some helpful terminal commands. The commands we will use are:
cd
change directory. Lets you navigate around in the file structure.ls
list. Lists all the files in a directory.pwd
print working directory. Tells you where you currently are in the file system.cat
concatenate. Outputs the contents of a file.In the terminal, use cd
to navigate to the repository you just cloned. You should be able to do this by typing the following command:
cd lab2-xxxx
Where lab2-xxxx is the name of your repository.
Now that you are in the repository, type ls
in the terminal. This should give you a list of all the lab files, which will look like this:
Note that one of the lab files is a directory called warmup1. Type
cd warmup1
To move to the warmup1 directory. Type ls
in the terminal to see what is inside the warmup1 directory. Now, use cd
to move into the abracadabra directory.
Terminal Autocomplete
You can hit tab and the terminal will autocomplete the rest of filenames. So if you type cd ab
and then tab, it will autocomplete to cd abracadabra
.
Now we’re several directories deep, but the command prompt in the terminal only shows the current directory. If we want to see exactly where we are in the system, we can type pwd
into terminal. Do that now, and you should see:
Now, let’s say we want to go up a level to get back to the warmup1 directory. To do this, type in the terminal
cd ..
The cd
command followed by two dots will always take you to the directory one level above the one you’re currently in. (Type pwd
to make sure it took you to the right place).
Now, use cd
and ls
to explore all of the directories in the warmup1 directory. You should be able to find a directory named hiddensquirrel that contains a text file named shhh.txt
. On the command line, type the following command, replacing name with your name.
echo "name" >> shhh.txt
This command will add your name to shhh.txt
, which you can verify using cat
by typing the following command into the command line:
cat shhh.txt
Use the git commands add
, commit
and push
to save your changes to shhh.txt
before you move on to the next part of the warmup.