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)"cd .. <ENTER>
cd . <ENTER>
cd .\John <ENTER>
cd John <ENTER>
.cd .. <ENTER>
Absolute paths
cd C:\John <ENTER>
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.