Last updated:
To go back one directory in the Ubuntu or Linux terminal, type cd .. (with a space between cd and the two dots) and press Enter. You move to the parent of the folder you are in. The commands below work the same in the default Bash shell on Ubuntu 26.04, 24.04 and 22.04, Debian and other Linux distributions, because cd is a shell built-in, not a package that changes between releases.
Quick answer
| You want to | Command |
|---|---|
| Go up one directory (parent folder) | cd .. |
| Go up two directories | cd ../.. |
| Go up three directories | cd ../../.. |
| Go back to the previous directory you were in | cd - |
| Go to your home directory | cd, cd ~ or cd "$HOME" |
| Go to the root of the file system | cd / |
| Remember a folder and come back to it later | pushd /path, then popd |
| Check where you are now | pwd |
“Back” can mean two different things, and they use different commands. Up means the parent folder in the directory tree (cd ..). Back in the browser sense means the last folder you were in, wherever it was (cd -). The sections below show both, with the output you should see.
Check where you are first with pwd
Before you move, print the current working directory with pwd. The prompt also shows it (for example ~/my-documents, where ~ is your home folder), but pwd always prints the full path:
pwd
Use ls to see the folders you can move into, or list only the directories if the folder is crowded with files.
Go back one directory with cd ..
Every directory contains a special entry named .. that points to its parent. Changing into it takes you one level up:
cd ..
Example run in Bash 5.2 on Ubuntu 24.04, starting in a nested project folder:
$ cd /tmp/demo/projects/web/src
$ pwd
/tmp/demo/projects/web/src
$ cd ..
$ pwd
/tmp/demo/projects/web
In the screenshot below, the user goes from ~/Desktop back to the home directory /home/linuxways:

The space matters. Typing cd.. without a space does not work in Bash. You get bash: cd..: command not found, because the shell looks for a program literally called cd... (Windows Command Prompt accepts cd.., which is why this mistake is so common.)
Go up two or more directories with cd ../..
Chain .. entries with slashes to climb several levels in one command. Each .. is one level:
cd ../.. # two levels up
cd ../../.. # three levels up
Continuing the example above, from /tmp/demo/projects/web:
$ cd ../..
$ pwd
/tmp/demo

You can also go up and then into a sibling folder in one step, for example cd ../images moves from ~/site/css to ~/site/images. Three dots on their own (cd ...) are not a shortcut in Bash; you get cd: ...: No such file or directory.

Go back to your home directory
From anywhere in the file system, any of these takes you to your home directory (for example /home/linuxways):
Stuck at this step? Ask us, it is free and include the exact error.
cd
cd ~
cd "$HOME"

cd ~ gives the same result, as the next two screenshots show from a different starting folder (~/extFiles):


The tilde also works inside longer paths, for example cd ~/Downloads. Use cd / if you want the very top of the file system instead of your home folder.
Go back to the previous directory with cd –
cd - switches to the directory you were in before the last cd, and prints its path. Bash keeps that path in the OLDPWD variable. Run cd - again to jump back, which makes it handy for flipping between two folders such as a project and its log directory.
$ pwd
/tmp/demo
$ cd -
/tmp/demo/projects/web
In the screenshot below, the user is in /home/linuxways and cd - returns them to ~/my-documents/extractFiles/MyFiles:

In a brand-new shell where you have not changed directory yet, there is no previous directory and Bash answers cd: OLDPWD not set.
Go back several steps with pushd and popd
cd - only remembers one previous folder. When you need to visit a few places and then return to where you started, use the directory stack built into Bash. pushd changes directory and remembers the old one; popd takes you back, one step at a time; dirs -v lists the stack.
$ cd /tmp/demo
$ pushd projects/web/src
/tmp/demo/projects/web/src /tmp/demo
$ pushd /etc
/etc /tmp/demo/projects/web/src /tmp/demo
$ dirs -v
0 /etc
1 /tmp/demo/projects/web/src
2 /tmp/demo
$ popd
/tmp/demo/projects/web/src /tmp/demo
$ popd
/tmp/demo
$ pwd
/tmp/demo
This is especially useful in shell scripts, where you want to do some work in another folder and then reliably return.
cd .. and symbolic links
If you entered a folder through a symbolic link, cd .. goes back to the folder that holds the link, not the real parent. That is Bash’s default “logical” mode. Add -P to follow the real (physical) path instead:
$ ln -s /tmp/demo/projects/web/src /tmp/demo/srclink
$ cd /tmp/demo/srclink
$ cd ..
$ pwd
/tmp/demo
$ cd /tmp/demo/srclink
$ cd -P ..
$ pwd
/tmp/demo/projects/web
Troubleshooting
| Error or symptom | Cause | Fix |
|---|---|---|
cd..: command not found | No space between cd and .. | Type cd .. |
cd: too many arguments | The folder name contains a space, e.g. cd My Files | Quote it: cd "My Files", or escape the space: cd My\ Files |
cd: name: No such file or directory | Typo, wrong letter case (Linux is case-sensitive), or the folder is not inside the current one | Run pwd and ls, press Tab to auto-complete the name |
cd: OLDPWD not set | You ran cd - before changing directory in this shell | Change directory once first, or give the full path |
cd: name: Permission denied | You lack execute (x) permission on that directory | Check with ls -ld name; use a different account or fix the permissions if it is your folder |
cd .. lands somewhere unexpected | You came in through a symbolic link | Use cd -P .. |
Running cd inside a script only changes the directory of that script’s own shell; your terminal stays where it was after the script ends. To change the directory of the current terminal, run the commands directly or load the script with source script.sh.
Once you can move around comfortably, the next steps are usually finding where a file is located and creating files from the command line. For a printable list of everyday commands, see the Linux and Windows command cheat sheet.