Welcome guest


cd - Change Directory

The cd command is used to move around, or "navigate through" the file tree. This effectively changes your current working directory to a different path name.

Example

If your current working directory was EosLabs, how would you go back to your home directory (~/)?

Ask yourself:

Q: What am I doing? A: Navigating through the file tree.
Q: How do I do that? A: Using the cd command.
Q: What are the path names? A: I am in EosLabs, I want to go to my home directory.

Changing Directory on the File Tree

Example 2

If your current working directory was ~/ (your home directory), how would you go to the EosLabs directory?

Ask yourself:

Q: What am I doing? A: Navigating through the file tree.
Q: How do I do that? A: Using the cd command.
Q: What are the path names? A: I am in my home directory and I am going to the EosLabs directory.

Second Exmaple Using a File Tree

Note: A common mistake is to assume that since the directories users and info are both under the same directory (eos.ncsu.edu), then you don't have to start at /afs/eos.ncsu.edu/. However, Linux does not work this way. If you were to type:

eos% cd eos.ncsu.edu/courses/e/e115/common/EosLabs

it would not work. It would give you the error, "No such file or directory."

Example 3

If your current working directory was lab-3, how would you go to the EosLabs directory?

Ask yourself:

Q: What am I doing? A: Navigating through the file tree.
Q: How do I do that? A: Using the cd command.
Q: What are the path names? A: I am in the lab-3 directory and I want to go to the EosLabs directory.

Third Example Using a File Tree

Note that there is a space between the 'cd' and the two dots.  In a Microsoft Windows environment, a space is optional.  However, in a Linux/UNIX environment, the space is necessary.