Linux command list

cd command: move between directories

__ __ _ _____
\ \ / /__| |_|_ _|__ _ __ _ __ ___
\ \ /\ / / _ \ '_ \| |/ _ \ '__| '_ ` _ \
\ V V / __/ |_) | | __/ | | | | | |
\_/\_/ \___|_.__/|_|\___|_| |_| |_| |_
 
A sandbox for trying cd. Nothing here can touch your real files.
user@webterm:~$
 

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

Syntax

cd [directory]

Running cd with no argument takes you to your home directory.

Try it first

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.

Ways to write the destination

What you typeWhere you end up
cd projectInto project, inside the current directory
cd ..One level up, into the parent
cd ../..Two levels up
cd /home/user/projectAt the absolute path you gave
cd ~Your home directory
cdThe 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

When you actually reach for it

SituationWhat to type
Step up one level in a projectcd ..
Check a log, then get back to workcd /var/log then cd -
Start over after digging too deepcd (home)
Follow written instructionscd /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.

Things that trip people up

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.

Practise it hands-on

>_WEBTERM LEARN

WebTerm Learn: from one command to actually using it

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

Related commands

pwd / ls

Frequently asked questions

What does cd stand for?
Change directory. It moves you to another directory.
Where does cd take me with no arguments?
To your home directory, the same as cd ~. It is the quickest way back when you are lost.
How do I go up one level?
Use cd .. and chain it as cd ../.. to go up two. The name .. always means the parent directory.
How do I jump back to where I just was?
Use cd -. It prints the path it is moving to, then moves. Handy when you are switching between two distant places.
What happens if I point cd at a file?
You get a Not a directory error. cd only moves into directories.
I ran cd but ls shows the same thing. Why?
The move probably failed. cd stays put when it errors, so run pwd to confirm where you are.