All courses

Terminal basics: where you are and running things

Use a terminal to see the current working directory, list files, change directory and run a program. Explain why an agent's commands run relative to the folder it was started in.

Read it card by card Start the whole course

The file is right there. Why can't it run?

You know `app.py` sits in your `Projects/todo` folder. You open a terminal, type `python app.py`, and get: `python: can't open file '/Users/sam/app.py': [Errno 2] No such file or directory` The file exists, and Python works. So why does it look in `/Users/sam`? And when you later start an AI agent from this same terminal, which folder will it work in?

A terminal is always standing in one folder

A terminal is always "in" exactly one folder, its **current working directory**. A new terminal usually starts in your home folder, here `/Users/sam`. Any file name you give a command without a full location, like `app.py`, is looked up only in that folder. So Python looked for `/Users/sam/app.py`, not in your project. Program names like `python` are found differently, in the system's standard program folders. That's why Python itself still ran. An agent started from this terminal starts in the same folder. File names in its commands are looked up from there too.

Four moves: where, what, go, run

- `pwd`: print where you are. - `ls`: list what's in this folder. - `cd <folder>`: move into a folder. `cd ..` goes up one level. `cd ~` goes home. - `<program> <file>`, e.g. `python app.py`: run something. On many Macs and Linux machines the command is `python3`. A **relative path** (`src/app.py`) starts from where you are. An **absolute path** (`/Users/sam/...`) starts from the top of the disk. In Windows PowerShell, `pwd`, `ls` and `cd` work too, and absolute paths start with a drive letter, like `C:\Users\sam`.

Finding the project and running it

Check where you are, look around, move in, check again, then run. Lines without `$` are the terminal's output.
$ pwd
/Users/sam
$ ls
Desktop  Documents  Projects
$ cd Projects/todo
$ pwd
/Users/sam/Projects/todo
$ ls
README.md  app.py
$ python app.py
Todo list: 0 items
$ cd ..
$ pwd
/Users/sam/Projects

An agent started in the wrong folder

You open a terminal and immediately start the agent (e.g. `claude` or `codex`). ▸ You: fix the typo in app.py ⚙ Run: ls It sees `Desktop Documents Projects`. There is no `app.py`. It may search your whole home folder or create a new `app.py` there. Instead, quit the agent. Run `cd Projects/todo`, then check with `pwd` and `ls`. Start the agent again. In an editor with a built-in agent, such as Cursor, the folder you open plays the same role.

Where you start is where it works

Every command runs from the current working directory. Check it with `pwd` and `ls`, and move with `cd`. Start an agent inside your project folder, because the file names in its commands are looked up from there.

On Bytewise this lesson comes in small steps with a check at the end, and the app brings it back right before you would forget it.