Decoding “Cd Create”: Navigating vs. Building in the Terminal
If you are just starting out with the command line (whether in Linux, macOS Terminal, or Windows Command Prompt), you might find yourself mixing up commands. One common point of confusion is looking for a command like “cd create”—expecting a single magic phrase to both make a new folder and jump right inside it.
As it turns out, cd and creation are two separate operations. Understanding how they work apart—and how to combine them—is a game-changer for working efficiently in code and files.
1. The Core Commands: cd and mkdir
To manage your files effectively via the terminal, you need a partnership between two distinct tools:
cd(Change Directory): This command is your vehicle for moving around. Typingcd Documentsshifts your current location into the Documents folder.mkdir(Make Directory): This is the actual command used to create a brand-new folder from scratch. Typingmkdir my-projectbuilds an empty folder named “my-project” right where you are.
Neither command does the other’s job by default. cd won’t build a folder that doesn’t exist yet, and mkdir won’t move you inside the folder you just made.
2. The Traditional Workflow
Usually, if you want to create a workspace and start working in it, you have to write a two-step sequence:
mkdir my-new-app
cd my-new-app
While typing two lines isn’t the end of the world, developers love shortcuts. When you are building projects all day long, repeating those two steps adds up.
3. How to Get a “Cd Create” Shortcut
If you want a true “cd create” workflow—where a single command builds a directory and immediately moves you into it—you can easily create your own custom shortcut or shell function.
If you use Bash or Zsh (common on Linux and macOS), you can add a custom function to your configuration file (like .bashrc or .zshrc):
mkcd() {
mkdir -p "$1" && cd "$1"
}
Once you save that function, you can simply type:
mkcd my-new-app
This tiny snippet automatically runs mkdir -p (which creates the directory, including any parent folders if needed) and instantly shifts your terminal session into that new space.
Summary Checklist
- Use
mkdir [folder]to create. - Use
cd [folder]to navigate. - Use a custom
mkcdfunction if you want them combined into a seamless “cd create” action!
Tip: Always check your current location using
pwd(Print Working Directory) if you ever feel lost in your file tree.
Leave a Reply