Working directory cd my-axum-app

Learn how to navigate into your newly created Axum project folder using the cd command, verify you are in the right place, and avoid common beginner mistakes with terminal directories.

Right after cargo new my-axum-app finishes, your terminal is still sitting in whatever folder you ran that command from. The new project exists as a subfolder named my-axum-app, but nothing has moved you inside it yet. The command that moves you there is cd my-axum-app. This page explains what that command does, why it matters for every single command that follows, and the small set of habits that prevent most beginner confusion around directories.

What a working directory is

Every terminal session has a current working directory. This is the folder your commands operate from. When you run a command, the terminal first looks at that folder to understand what you are referring to.

If you type a name without a full path, the terminal resolves that name relative to your current working directory. If you run cargo run, the terminal does not search your whole computer for a Rust project. It looks in the folder you are currently standing in for a Cargo.toml file. If that file is not there, Cargo will refuse to run and tell you so.

The phrase "standing in" is a useful mental model. Think of the terminal as a small figure that exists inside exactly one folder at a time. You can see where that figure is by listing the contents of the current folder. Moving the figure to a new folder is what cd does.

Why you must move inside the project folder

cargo new my-axum-app creates a folder named my-axum-app inside your current directory. The command does not make that new folder your current location. Your terminal figure stays outside the project. If you try to run project commands from outside, they fail.

Consider this sequence after creating the project:

~/projects $ cargo new my-axum-app
    Creating binary (application) `my-axum-app` package
note: see more `Cargo.toml` keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
~/projects $ cargo run
error: could not find `Cargo.toml` in `~/projects` or any parent directory

The error is not mysterious. You are still standing in ~/projects, a folder that contains the project but is not itself the project. The my-axum-app folder is one level below you. Cargo looks up the folder tree for a Cargo.toml and does not find one.

The fix is to move inside:

~/projects $ cd my-axum-app
~/projects/my-axum-app $ cargo run

Now the terminal figure is inside the project folder. Cargo.toml is immediately visible. Every command that needs to operate on the project will now work.

Forgotten cd is the most common setup blocker:

Many beginners run cargo run immediately after cargo new and hit the could not find Cargo.toml error at least once. The cause is almost always that the terminal is still one folder too high. Run pwd to see where you are, and cd my-axum-app to move into the project.

The basic command and its output

The simplest form has no surprising output:

$ cd my-axum-app

On success, cd prints nothing. An empty result in the terminal often signals success for commands that move around the file system. The terminal prompt itself is the confirmation. Most shells are configured to display the current directory in the prompt, so after the command you should see something like:

~/projects/my-axum-app $

The exact formatting depends on your shell. On some systems the prompt might show the full path, on others only the folder name my-axum-app, and on others the prompt might look unchanged. Do not rely solely on the prompt. Use pwd for certainty.

Verifying where you are with pwd

pwd stands for print working directory. It outputs the absolute path of your current location:

$ pwd
/home/yourname/projects/my-axum-app

This is the fastest way to remove all doubt. If pwd does not end with my-axum-app, you are not inside the project yet.

A complete verification loop after creating the project looks like this:

$ cd my-axum-app
$ pwd
/home/yourname/projects/my-axum-app
$ ls
Cargo.toml  src

ls lists the visible contents of the current folder. Seeing Cargo.toml and src is a strong signal that you are inside a Rust project. If ls shows nothing, or shows files that look unrelated, you are in the wrong folder.

You are in the right place when pwd and ls agree:

If pwd ends with my-axum-app and ls shows at least Cargo.toml and src, the working directory is correct. Every project command from this point will target your Axum project.

Moving in and out of the project folder

Beginners often need to leave the project folder and return to it. Understanding the two small commands that handle this removes most navigation anxiety.

Moving up with cd ..

The .. symbol means "the parent folder" - the folder one level above where you currently are. From inside my-axum-app, this command exits back to the folder that contains it:

~/projects/my-axum-app $ cd ..
~/projects $

This is useful when you need to operate on multiple projects, or when you accidentally enter a project and want to back out.

You can combine .. with pwd to trace your climb:

~/projects/my-axum-app $ cd ..
~/projects $ pwd
/home/yourname/projects

Moving back in with a named path

Once you are outside, the same cd my-axum-app command brings you back, but only if your parent folder is still the same:

~/projects $ cd my-axum-app
~/projects/my-axum-app $

The behavior changes depending on where you currently are. From ~/projects, cd my-axum-app works because my-axum-app is a child of ~/projects. From your home directory, the same command would fail unless a folder named my-axum-app also exists there.

Absolute paths versus relative paths

The basic cd my-axum-app uses a relative path - relative to your current location. There is another way to refer to the same folder using an absolute path, which starts from the root of the file system and never changes meaning based on where you are.

A relative path:

$ cd my-axum-app

An absolute path:

$ cd /home/yourname/projects/my-axum-app

Both commands reach the same folder when you run them from ~/projects. The relative version is shorter, which is why it is the standard pattern in Axum setup guides. The absolute version works no matter where you are currently standing, because it describes the full route from the root.

Which one should a beginner use? In most cases, relative. It is shorter, it matches the documentation, and it keeps your workflow tied to a clear parent folder. Reserve absolute paths for situations where you are far away from the project, or where a script needs to be sure of the location regardless of where it runs.

You can confirm that both forms point to the same place:

$ cd /home/yourname/projects/my-axum-app
$ pwd
/home/yourname/projects/my-axum-app
$ cd ..
$ cd my-axum-app
$ pwd
/home/yourname/projects/my-axum-app

Both sequences end at the same folder.

Using tab completion to avoid typos

Folder names can be long, and Rust projects often have hyphenated names like my-axum-app. Typing that full name repeatedly is not necessary. Nearly every shell supports tab completion: type the first few characters, press the Tab key, and the shell fills in the rest.

For example:

$ cd my-

Press Tab. If my-axum-app is the only folder in the current directory that starts with my-, the shell completes it:

$ cd my-axum-app

If multiple folders start with my-, the shell may not be able to choose. In that case, press Tab twice quickly. Most shells will list the matching options:

$ cd my-
my-axum-app  my-other-project  my-scripts
$ cd my-

Type one more character to disambiguate, then press Tab again. For my-axum-app, typing my-a then Tab should be enough.

Tab completion has a hidden benefit: it only completes folder names that actually exist in the current directory. If you type cd my- and press Tab and nothing appears, no folder starting with my- exists there. That is an immediate signal that you are in the wrong parent folder or that the project was created with a different name.

What happens if you cd into the wrong folder

The cd command rarely produces an error when the folder exists, even if that folder is not the project. This makes wrong-folder mistakes silent. You can accidentally cd into a sibling project, a documentation folder, or an empty directory, and the command will happily succeed.

The protection is the verification habit. After any cd, run pwd and ls before running a build or run command:

$ cd my-axum-app
$ pwd
/home/yourname/projects/my-axum-app
$ ls
Cargo.toml  src

If ls does not show Cargo.toml, stop. Do not run cargo run until you have moved to the correct folder.

cd succeeding does not mean you are in the right folder:

cd only fails when the target folder does not exist. It succeeds silently for any folder that does exist, including the wrong one. Always verify with pwd and ls before assuming your project commands will work.

Fixing a failed cd

When the target folder does not exist, cd prints an error and leaves you where you were:

$ cd my-axum-app
bash: cd: my-axum-app: No such file or directory

This error almost always means one of two things. Either you are not in the parent folder that contains my-axum-app, or the folder has a different name. Recover by listing the current directory:

$ ls
some-other-folder  notes.md

If my-axum-app is absent, use cd .. to climb toward the parent, then ls again. Follow the trail until you find the folder, then use the correct name.

Using cd in a typed sequence versus interactive shell

Most Axum tutorials show commands one at a time, each on its own line. That is the best way to learn because you can verify each step before moving on. For reference, the full sequence from project creation to entering the project is:

$ cargo new my-axum-app
$ cd my-axum-app
$ pwd
/home/yourname/projects/my-axum-app

You can also type multiple commands on one line by separating them with &&. This runs the second command only if the first succeeds:

$ cargo new my-axum-app && cd my-axum-app && pwd

For an absolute beginner, this compact form hides what is happening. If something fails, it is harder to tell which part broke. Prefer one command per line until the individual steps feel natural.

How cd relates to Cargo commands

Every subsequent step in setting up the Axum project assumes the terminal is inside the project folder. Commands like cargo add, cargo run, and cargo build all read Cargo.toml from the current working directory.

If you run cargo add axum from the parent folder instead of inside my-axum-app, Cargo will report that no project exists there. The command you think is "adding Axum to my project" is actually trying to add Axum to a folder with no project in it.

The working directory is not a detail that only matters at the start. It matters before every Cargo command. A common pattern for a beginner session looks like this:

$ cd my-axum-app
$ pwd
/home/yourname/projects/my-axum-app
$ cargo add axum
$ cargo add tokio --features full
$ cargo run

None of those Cargo commands would work from the parent directory. The cd at the top is what makes the whole sequence possible.

Switching to another terminal or after a reboot

The current working directory is a property of the terminal session, not of the project. If you close the terminal and open a new one, the new session typically starts in your home directory - not inside my-axum-app.

This surprises many beginners who close a terminal after a successful session, open a new one, and immediately type cargo run again. The error returns:

$ cargo run
error: could not find `Cargo.toml` in `/home/yourname` or any parent directory

The project did not break. The new terminal simply started in a different folder. Move back to the project with cd:

$ cd projects/my-axum-app
$ cargo run

If you are not sure what path to use from your home directory, use ls to see the top-level folders, then descend one level at a time.

Every new terminal starts fresh:

There is no memory of the previous working directory between terminal sessions. Treat each new terminal as starting from scratch and navigate back to the project with cd before running project commands.

Common mistakes and quick fixes

The most frequent errors around cd fall into a small set of patterns.

Running Cargo commands before cd. This is the canonical mistake. Fix it by running cd my-axum-app and then re-running the Cargo command.

Typing cd my-axum-app from inside the project already. If you are inside my-axum-app and type cd my-axum-app again, the shell looks for a child folder with the same name inside the project. That child does not exist, so you get an error. You are already where you want to be. No action needed other than verifying with pwd.

Assuming the project was created in your home directory. The project is created wherever you ran cargo new. If that was ~/projects, the project lives at ~/projects/my-axum-app. If that was your home directory, the path is different. Use pwd before cargo new to know the parent location, and use it again after cd to confirm the full route.

Not knowing the exact project folder name. Cargo creates the folder with the exact name you pass to cargo new. If you ran cargo new my-axum-app, the folder is my-axum-app, with lowercase letters and hyphens. A different capitalization or underscore will not match. Use ls from the parent to see the exact name.

Forgetting you are in a different project. If you created multiple Rust projects, it is possible to cd into the wrong one. The result is Cargo commands running against the wrong project, which can be confusing. The ls and pwd verification habit prevents this.

Working with cd on Windows PowerShell and Command Prompt

The instructions above use Unix-style examples, but the cd command exists on Windows too. The syntax is the same: cd my-axum-app. The path separators differ in some contexts - Windows uses backslashes (\) for absolute paths, but Rust tooling and modern PowerShell also accept forward slashes in many cases.

The verification commands are nearly identical. On Windows PowerShell:

$ cd my-axum-app
$ pwd
Path
----
C:\Users\yourname\projects\my-axum-app

On older Command Prompt, pwd does not exist by default. Use cd with no arguments to print the current directory:

C:\Users\yourname\projects> cd my-axum-app
C:\Users\yourname\projects\my-axum-app> cd
C:\Users\yourname\projects\my-axum-app

Running cd with no arguments behaves differently across shells. On Unix-like shells, cd with no arguments typically returns to the home directory. On Windows Command Prompt, it prints the current directory. PowerShell also treats cd with no arguments as returning to the home directory. For a beginner on Windows, the safest cross-shell habit is to use pwd in PowerShell and cd alone in Command Prompt to see where you are.

cd with no arguments behaves differently per shell:

On Unix-like shells and PowerShell, running cd with no arguments jumps to your home directory. On Windows Command Prompt, it prints the current directory. Do not rely on this behavior as a verification method unless you know your shell.

A realistic first session with verification built in

Bringing the pieces together, a careful beginner workflow after creating the project looks like this:

$ cargo new my-axum-app
    Creating binary (application) `my-axum-app` package
note: see more `Cargo.toml` keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
$ cd my-axum-app
$ pwd
/home/yourname/projects/my-axum-app
$ ls
Cargo.toml  src

At this point, the terminal figure is inside the project. The pwd output confirms the full path ends with the expected folder name. The ls output confirms Cargo.toml and src are present.

From here, the project is ready for the next steps: adding the web framework crates, editing src/main.rs, and running the server. All of those steps depend on the working directory being correct. The cd command was small, but it unlocked everything that follows.

Summary

The cd my-axum-app command does one small thing with outsized consequences: it moves the terminal from the parent folder into the project folder. The decision framework for paths is simple: use a relative path when you are already near the project, because it is short and matches the documentation; use an absolute path when you are far away or when a script must land in the same place no matter where it starts. In both cases the verification is the same - pwd to confirm the folder, ls to confirm Cargo.toml and src are visible - and a new terminal always starts outside the project again, so the first command of every session is navigation, not building.