Next: Input/Output, Previous: Environment, Up: Running [Contents][Index]

### 4.5 Your Program’s Working Directory

Each time you start your program with `run`, it inherits its working directory from the current working directory of GDB. The GDB working directory is initially whatever it inherited from its parent process (typically the shell), but you can specify a new working directory in GDB with the `cd` command.

The GDB working directory also serves as a default for the commands that specify files for GDB to operate on. See Commands to Specify Files.

`cd [directory]`

  Set the GDB working directory to directory. If not given, directory uses `'~'`.

`pwd`

  Print the GDB working directory.

It is generally impossible to find the current working directory of the process being debugged (since a program can change its directory during its run). If you work on a system where GDB is configured with the `/proc` support, you can use the `info proc` command (see SVR4 Process Information) to find out the current working directory of the debuggee.