Problem 1.2

Creating Folders

Lets go ahead and create some folders on our machine.

Linux Terminal

Open the Terminal. You will start in your home directory ~.

(trusty)robuntu@localhost:~$ 

That space between the : and the $ is your current working directory. For the sake of space, I will leave out the (trusty)robuntu@localhost: part and only show the current working directory (cwd). Like this:

~$ 

List ls

We want to be able to see what the cwd contains. To do this, we use the ls command.

~$ ls
Android   Downloads             Pictures
Desktop   IntelliJIDEAProjects  Sketchbook

Make Directory mkdir

Next, we want to make a folder specifically for your course-work. In the terminal, use the mkdir command followed by your last name to create a folder. We will then use ls to confirm that the directory was created.

~$ mkdir gallo
~$ ls
Android   Downloads   IntelliJIDEAProjects    Sketchbook
Desktop   gallo       Pictures

Change Directory cd

Lets jump into that folder we just created. To change the current working directory, we use the cd command.

~$ cd gallo
~/gallo$ 

You will notice that the path before the $ has changed. You are now in a different folder. If you list the contents of the directory you just created and opened, it won’t show anything because the directory is empty.

~/gallo$ ls
~/gallo$ 

Create File touch

In your personal, folder, use the touch command to create an empty file. You specify the name after the touch command.

~/lastname$ touch some-empty-file.txt
~/lastname$ ls
some-empty-file.txt

What to do next

  1. Use the mkdir command to create a folder to store your Programming By Doing solutions. Call the new directory pbd-solutions. Be sure your current working directory is your personal folder because mkdir will create the new folder in the cwd by default.
  2. Change directory to the pbd-solutions directory you just created.
  3. Create a folder called 01.2.
  4. Change your directory to that new 01.2 folder and use the touch command to create a file called EmptyFile.java. Confirm that it exists in the 01.2 folder by using ls.
  5. Now, move back a folder in the file-path by using cd ... You should now be in the pbd-solutions directory.
  6. Use mkdir again to create a folder within pbd-solutions called 02.

Note: the file-path we just created is ~(home)/your-lastname/pbd-soutions/02. You will need to navigate here for the next problem.


◄ 1.1: Compiler Check 2: Compiling Practice ►