cd changes the directory you are working in. Learn what .. , - and a bare cd each do, by running the commands in a real terminal in your browser.
Updated: 2026-09-04
cd [directory]
Running cd with no argument takes you to your home directory.
The terminal on this page starts in your home directory. Moving down changes what pwd reports.
$ pwd
/home/user
$ cd project
$ pwd
/home/user/project
$ cd src
$ pwd
/home/user/project/src
cd prints nothing when it succeeds. Silence is the success case; run pwd when you want confirmation.
| What you type | Where you end up |
|---|---|
cd project | Into project, inside the current directory |
cd .. | One level up, into the parent |
cd ../.. | Two levels up |
cd /home/user/project | At the absolute path you gave |
cd ~ | Your home directory |
cd | The same, with no argument |
cd - | Back to wherever you were before |
cd - is the one exception to the silence: it prints the path first.
$ cd ..
$ pwd
/home/user/project
$ cd -
/home/user/project/src
$ pwd
/home/user/project/src
| Situation | What to type |
|---|---|
| Step up one level in a project | cd .. |
| Check a log, then get back to work | cd /var/log then cd - |
| Start over after digging too deep | cd (home) |
| Follow written instructions | cd /an/absolute/path |
cd - earns its place when you are bouncing between two locations. You get back without retyping the path, which adds up when you are switching between logs and your working directory.
A missing destination is an error.
$ cd nothing
cd: nothing: No such file or directory
Either the name is a typo, or you are not where you thought. Run ls to look around, then try again.
You cannot cd into a file.
$ cd /home/user/project/README.md
cd: /home/user/project/README.md: Not a directory
cd only moves into directories. To read a file, use cat.
When cd errors, you have not moved.
It leaves you where you were. Check with pwd after an error, so the next command does not run somewhere unexpected.
Terminal for Beginners
Learn basic commands

Commands stick when they show up in a real sequence of work, not one at a time. There is a course that builds them up in order.
See the course