Command line tools

cd

cd: change directory.

The cd command is used to change the current working directory in the command line environment. This command allows you to navigate the file system of your computer. Changing the current working directory is a fundamental operation when managing files or running programs from the terminal.

Note that if the path contains spaces, you need to enclose it in quotes so that the cd command treats it as a single argument.

For example, if the path is /home/alex/my documents, you would run the command cd "/home/alex/my documents". You can use both single ' and double quotes ", but always use the same pair of quotes.

Also, note that on every operating system (except Windows), paths and commands are case-sensitive. For example, /home/Alex and /home/alex are two different paths.

Examples

Linux/macOS

Change to a specific directory:

cd /path/to/directory

Go up one directory level:

cd ..

Go up two directory levels:

cd ../..

Go back to the previously visited directory:

cd -

Change to the home directory:

cd ~

Windows (PowerShell)

PowerShell supports cd as an alias for its Set-Location cmdlet. The behavior and options are similar to Unix systems.

For a long time, Windows used backslashes (\) as directory separators, while Unix systems used forward slashes (/). However, modern versions of Windows support both types of separators. In my opinion, it's better to use forward slashes in PowerShell, as they're more compatible with Unix systems.

Change to a specific directory:

cd C:/path/to/directory

Go up one directory level:

cd ..

Go up two directory levels:

cd ../..

Go back to the previously visited directory:

cd -

Change to the home directory:

cd ~
© 2024-2025 GitByBit.All rights reserved.

Hi! I'm Alex, creator of GitByBit.

And this is Gitopedia—a reference that summarizes knowledge in my Git course.

Gitopedia is designed to be a personal knowledge base. When you progress through the main Git course in VS Code, you unlock all of these topics, one by one, bit by bit. This gives you time to digest the information and gradually build the mental model of Git. Here's an example of how it works:

Learning directly in VS Code lets you practice Git exactly as you would in real life, doing real jobs, writing real code. In addition, the course has access to your actual terminal, so it can point out mistakes, suggest workarounds, etc.

The course is FREE, there are no Ads or other bullshit. There are optional premium add-ons you can purchase, mainly to support my work (regrettably, I have to eat every day), but that's totally up to you.

Learn Git in VS Code