Tutorial: Introduction to the Command Line

3. Drives and Directories

3.3. Change directory

1. Now go to the newly created directory "John" by typing:
cd John <Enter>

cd means "change directory". You can see that the command prompt has changed to C:\JOHN

Note that DOS is not case sensitive (it interprets upper and lowercase in a similar way), so you could also have typed cd john.

2. List the contents of the directory John (use the command that you've learned before).

Relative paths

Now you'll see that the directory is not empty. There are two directories, namely . and ..

Actually, the directory is empty, but it also shows the relative paths:

 . means "current directory"

.. means "mother directory (or one directory up)"

3. Type
cd .. <ENTER>

4. Check the command prompt.

We're back in the directory (root of the C-Drive) where we started the exercise.


5. Now type :
cd . <ENTER>

6. What is the result of this command? Explain why.

7. We can go back to directory John using the relative path, type
cd .\John <ENTER>

Note that this is the same as cd John <ENTER> .

8. Go one directory up to go back, type
cd .. <ENTER>

Absolute paths

We can also use absolute paths to navigate on our drive. Absolute paths always start from the root of a drive, in our case C:\.

9.  Type
cd C:\John <ENTER>

10. If we want to go to the root (drive C) we can do it using the absolute path, type
cd \ <ENTER>

Why bother about absolute and relative paths?

11. Go back to the directory called John. You can choose if you want to use the relative or absolute path

12. Type
cd ..\Peter <ENTER>

13. Look at the prompt and explain what this command did.

Both ways of changing directories are equivalent. Why bother than? Well, if you move your files that are organized in directories and subdirecties to another drive (e.g. drive D), than your absolute paths will not work, while your relative paths will still refer to the same locations. This is specifically important when writing scripts, which we'll do later.