Changing directories in Gemini CLI uses the same `cd` command you would use in any terminal
The Gemini CLI is Google's command-line tool for interacting with the Gemini API. Like any terminal environment, you navigate between folders using the `cd` (change directory) command. The syntax and behavior are identical to what you would use in Bash, Zsh, or PowerShell — the difference is that Gemini CLI runs these commands within its own shell context.
To change to a different directory, type `cd` followed by a space and the path you want to move to. You can use absolute paths (starting from the root of your system) or relative paths (starting from where you are now). The command executes immediately when you press Enter.
Key Takeaways
- Use `cd` followed by a folder path to move between directories in Gemini CLI, just as you would in a standard terminal.
- Relative paths like `cd Documents` move into a folder inside your current location, while absolute paths like `cd /Users/username/Documents` start from your system root.
- Type `cd ..` to move up one level to the parent directory, or `cd ~` to jump directly to your home folder.
- Use `pwd` to see your current directory path if you become unsure of your location.
Basic syntax for moving between folders
The simplest form of the command is `cd` plus the folder name. If you are in your home directory and want to move into a folder called `Projects`, you would type:
`cd Projects`
Gemini CLI will move you into that folder. If the folder does not exist or you do not have permission to enter it, the terminal will return an error message telling you so. From there, any commands you run will execute within the `Projects` directory.
Using absolute paths to jump anywhere
An absolute path starts from the root of your file system and specifies the complete route to a folder. On macOS and Linux, this begins with a forward slash. On Windows, it begins with a drive letter like `C:\`.
For example, on macOS or Linux you might type:
`cd /Users/username/Documents/Work`
On Windows, the equivalent would be:
`cd C:\Users\username\Documents\Work`
Absolute paths let you move to any folder on your system from anywhere, without needing to navigate step by step. This is useful when you want to jump directly to a project folder that is nested several levels deep.
Moving up the directory tree
To move up one level to the parent directory, use `cd ..` (that is `cd` followed by two periods with a space between):
`cd ..`
If you are in `/Users/username/Documents/Work`, this command moves you to `/Users/username/Documents`. You can chain multiple `..` commands together to move up several levels at once. For example, `cd ../..` moves up two levels.
To jump directly to your home directory from anywhere, type:
`cd ~`
The tilde (`~`) is a shortcut that always refers to your home folder, regardless of where you currently are in the file system.
Checking your current location
If you lose track of which directory you are in, use the `pwd` command (print working directory):
`pwd`
This prints the full path of your current location to the terminal. It is helpful when you are navigating through many folders and need to confirm where you are before running a command that depends on file location.
Listing folder contents before moving
Before changing directories, you may want to see what folders exist in your current location. Use the `ls` command (on macOS and Linux) or `dir` command (on Windows) to list the contents:
`ls` (macOS/Linux)
`dir` (Windows)
This shows you all files and folders in the current directory, so you can verify the exact name of the folder you want to move into. Folder names are case-sensitive on macOS and Linux, so `cd Documents` and `cd documents` are not the same.
Handling folder names with spaces
If a folder name contains spaces, you must either wrap the path in quotes or use a backslash to escape the space. For example, if you have a folder called `My Projects`, you would type:
`cd "My Projects"`
Or:
`cd My\ Projects`
Without quotes or escaping, the terminal interprets the space as a separator between commands and will return an error. Using quotes is usually simpler and more readable.
Frequently Asked Questions
What happens if I type a folder name that does not exist?
Gemini CLI returns an error message like "No such file or directory" and stays in your current location. Check the spelling of the folder name, use `ls` or `dir` to see what folders are actually present, and try again with the correct name.
Can I use tab completion to finish folder names automatically?
Yes. Type `cd` and the first few letters of the folder name, then press Tab. Most terminal environments, including Gemini CLI, will auto-complete the rest of the name if it is unambiguous. If multiple folders start with those letters, pressing Tab again cycles through the options.
How do I go back to the previous directory I was in?
Use `cd -` (cd followed by a hyphen). This switches you back to the directory you were in before your last `cd` command. Typing it again switches you back to where you were before that.
Does changing directories in Gemini CLI affect my system directories?
No. When you close Gemini CLI, your system returns to whatever directory your terminal was in before. Changes made within Gemini CLI are local to that session only.