The basic command to change directory

To move to a different folder in command line, type cd followed by a space and the folder name or path you want to enter. On Windows, Mac, and Linux, the command works the same way. For example, typing cd Documents moves you into a folder called Documents in your current location.

After you press Enter, the command line shows your new location in the prompt. On Mac and Linux, you'll typically see a tilde (~) or folder name before the dollar sign ($). On Windows Command Prompt, you'll see the drive letter and full path before the greater-than sign (>).

Key Takeaways

  • The cd command moves you between folders; type it followed by the folder name or path you want to enter.
  • Use cd .. to move up one level to the parent folder, or cd alone to return to your home directory.
  • Type the full path with forward slashes (Mac and Linux) or backslashes (Windows) to jump directly to a folder anywhere on your system.
  • Use pwd on Mac and Linux, or cd with no arguments on Windows, to see exactly where you are right now.
  • Folder names with spaces need quotes around them, like cd "My Documents", or the command will fail.

Moving up to the parent folder

To go back up one level to the folder that contains your current folder, type cd .. (that's cd, a space, and two periods). Each time you run this command, you move up one level in the folder structure.

If you're in Documents/Work/Projects and you type cd .., you'll move to Documents/Work. Type it again and you'll be in Documents. This is useful when you've navigated deep into nested folders and need to backtrack quickly.

Jumping to your home directory

Type cd with nothing after it to return to your home directory instantly, no matter where you are in the folder structure. This is faster than typing cd .. multiple times when you're several levels deep.

On Mac and Linux, you can also type cd ~ to do the same thing. The tilde (~) is a shortcut that always means "your home directory." On Windows, your home directory is typically C:\Users\YourUsername.

Using full paths to jump anywhere

Instead of moving one folder at a time, you can type the complete path to jump directly to any folder. On Mac and Linux, paths use forward slashes: cd /Users/YourName/Documents/Work/Projects. On Windows, use backslashes: cd C:\Users\YourName\Documents\Work\Projects.

If your path starts with a slash (Mac and Linux) or a drive letter (Windows), the command line treats it as an absolute path — it starts from the root of your system and ignores where you currently are. This is helpful when you know exactly where a folder lives but don't want to navigate there step by step.

Handling folder names with spaces

If a folder name contains spaces, wrap the entire name or path in double quotes. For example, cd "My Documents" or cd "Program Files". Without the quotes, the command line reads the space as a separator and tries to interpret the second word as a separate command, which causes an error.

On Mac and Linux, you can also use a backslash before the space instead of quotes: cd My\ Documents. Both methods work, but quotes are simpler and work across all systems.

Checking where you are right now

On Mac and Linux, type pwd (print working directory) to see the full path of your current location. This is useful when you've navigated through several folders and want to confirm exactly where you are before running other commands.

On Windows Command Prompt, type cd with no arguments to see your current path. In Windows PowerShell, use pwd just like Mac and Linux. If you're unsure which shell you're using on Windows, either command will work — one will just show the information and the other won't.

Common mistakes and how to fix them

The most frequent error is typing a folder name that doesn't exist or misspelling it. The command line will respond with "No such file or directory" or "The system cannot find the path specified." Double-check the spelling and make sure the folder is actually inside your current location.

Another common issue is forgetting quotes around folder names with spaces. If you see an error mentioning the second word of your folder name, add quotes and try again. On Windows, mixing forward slashes and backslashes in the same path can also cause problems — stick to backslashes for Windows paths and forward slashes for Mac and Linux.

Frequently Asked Questions

What's the difference between cd and pwd?

cd changes your location to a different folder. pwd (on Mac and Linux) shows you where you currently are without moving. Think of cd as the action and pwd as the confirmation of where you ended up.

Can I use cd to go to a folder on a different drive on Windows?

Yes, but you need to include the drive letter. Type cd D:\FolderName to move to a folder on the D drive. If you're on the C drive and just type the path without the drive letter, nothing happens — you have to specify which drive first.

What does the dot (.) mean in command line?

A single dot (.) means your current folder. Two dots (..) mean the parent folder — the one that contains where you are now. You'll see these used in paths and commands throughout command line work.

How do I navigate to a folder I just created?

Type cd FolderName exactly as you named it, matching uppercase and lowercase letters. On Mac and Linux, folder names are case-sensitive, so cd documents and cd Documents are different commands. On Windows, they're treated the same.

Can I use the up arrow key to repeat a cd command?

Yes. Press the up arrow key to cycle through your previous commands, including cd commands you've already typed. When you find the one you want, press Enter to run it again. This saves time when you navigate to the same folder repeatedly.