Linux Command Line Interface

Linux Command Line Interface

Sections: 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | Index | Next >

cd "Change Directory" Command

Learning objective: (3) Demonstrate the use of the cd command


Click on image to enlarge.

cd command to change directory

The "cd" command allows you to navigate down or up the hierarchy tree. You can move up/down one level at a time or many by providing the appropriate path. If a path begins with a "/" forward slash, the reference is the root as an absolute path. If the path does not start with a "/" forward slash, the reference is based on the current working directory as a relative path.

cd or cd ~ (home directory)

The "cd" command by itself or the "cd ~" will take you to your home directory. In this example, the last "cd" command takes you back to the home directory. You can see the results from the "ls" command.

cd path

The "cd path/path" takes you down a path or series of path in the hierarchy tree. In this example the command "cd my-document/" takes you down one level to the my-documents directory. You can see the results from the "ls" command.

cd .. (parent)

The "cd .." takes you up a path or series of path in the hierarchy tree by using "cd ../..".

cd / (root)

The "cd /" takes you to the root of the hierarchy tree. In this example the command "cd /" takes you to the root of the operating system. You can see the results from the "ls" command.

DOS: CD

The equivalent in DOS would be "CD" and works mostly the same with the exception of the "\" backslash path separator or root reference.


✏ Self Quiz!

Select the best response(s) for each question/statement. Use this opportunity to test *your* knowledge and not just move on...

1) The "cd" command can be used to...
Return to the home directory with "cd"
Return to the home directory with "cd ~"
Go up one level with "cd .."
Go to the system root with "cd \"

.


Thinking: How many directories are there between your home directory and the root?

Key terms: child, directory, parent, path, root

Resources:
To maximize your learning, please visit these Web sites and review their content to help reinforce the concepts presented in this section.

Quick links:
The cd Command
cd(1) - Linux man page
cd Command @ Wikipedia

Embedded Resources

Notes on navigation: Click inside the frame to navigate the embedded Web page. - Click outside the frame to navigate this page to scroll up/down between the embedded Web pages. - Click on the frame title to open that page in a new tab in most browsers. - Click on the the "Reload page" link to reload the original page for that frame.

The cd Command | Reload page | If frame is empty, click on the link to view the page in a new tab or window

cd(1) - Linux man page | Reload page | If frame is empty, click on the link to view the page in a new tab or window

cd Command @ Wikipedia | Reload page | If frame is empty, click on the link to view the page in a new tab or window

Sections: 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | Index | Next >