# Change default working directory in JupyterLab on Linux

**URL:** <https://discourse.jupyter.org/t/change-default-working-directory-in-jupyterlab-on-linux/11066>\
**Category:** JupyterLab\
**Tags:** how-to\
**Created:** [October 2, 2021, 9:17pm UTC](https://discourse.jupyter.org/t/change-default-working-directory-in-jupyterlab-on-linux/11066 "2021-10-02T21:17:57Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![jim761](https://avatars.discourse-cdn.com/v4/letter/j/f14d63/32.png) [@jim761](https://discourse.jupyter.org/u/jim761)\
**Post date:** [October 2, 2021, 9:17pm UTC](https://discourse.jupyter.org/t/change-default-working-directory-in-jupyterlab-on-linux/11066/1 "2021-10-02T21:17:57Z")

</div>

I’m new to JupyterLab. I want to change the default location notebooks are saved from ~/ (i.e. my home directory) to a mounted network location with the path /workspaces/Jupyter/ (or alternatively, another local directory I create outside of my home). I do not want all these .ipynb files cluttering up my home directory.

I looked at a number of answers, but as far as I can tell, none of them address my question because they are either specific to Windows or they focus on an older version of Jupyter. Also, because I am new to JupyterLab, I don’t want to screw things up by trying something that I’m not sure is correct. So I’m looking for the correct answer for changing the default working directory in JupyterLab on Linux.

These are the config files I currently have:

```
~/.jupyter/
├── lab
│ ├── user-settings
│ │ └── @jupyterlab
│ │ ├── console-extension
│ │ │ └── tracker.jupyterlab-settings
│ │ ├── fileeditor-extension
│ │ │ └── plugin.jupyterlab-settings
│ │ └── notebook-extension
│ │ └── tracker.jupyterlab-settings
│ └── workspaces
│ └── default-37a8.jupyterlab-workspace
├── migrated
└── nbconfig
    └── notebook.json
8 directories, 6 files

```

None of them contain the config keys I saw mentioned in the reference pages I checked.

```
$ grep -irP '(root_dir|notebook_dir)' ~/.jupyter/
$ echo $?
1

```

References:  
(EDIT: I am only allowed 2 links, but I checked many more)

- [How to change the Jupyter start-up folder - Stack Overflow](https://stackoverflow.com/questions/35254852/how-to-change-the-jupyter-start-up-folder "path - How to change the Jupyter start-up folder - Stack Overflow")

- [Working Directory · Issue #2980 · jupyterlab/jupyterlab](https://github.com/jupyterlab/jupyterlab/issues/2980 "Working Directory · Issue #2980 · jupyterlab/jupyterlab")

---

<div class="post-metadata">

**Author:** ![krassowski](https://yyz1.discourse-cdn.com/flex031/user_avatar/discourse.jupyter.org/krassowski/32/1685_2.png) [@krassowski](https://discourse.jupyter.org/u/krassowski)\
**Post date:** [October 3, 2021, 12:08am UTC](https://discourse.jupyter.org/t/change-default-working-directory-in-jupyterlab-on-linux/11066/2 "2021-10-03T00:08:16Z")

</div>

The question on SO that you linked has a “2021 update” from me ([path - How to change the Jupyter start-up folder - Stack Overflow](https://stackoverflow.com/a/40514875/6646912)), but I will quote it here for convenience:

> For recent `nbclassic` and JupyterLab\>=3 use `c.ServerApp.root_dir` instead of `c.NotebookApp.notebook_dir`.
> 
> For context see [migration guide](https://jupyter-server.readthedocs.io/en/stable/operators/migrate-from-nbserver.html) and [this question](https://stackoverflow.com/q/67797152/6646912) on differences between `server` and `notebook`.

So you would run `jupyter server --generate-config` and should be able to grep-find `root_dir` (even better, I think it will tell you where the config got generated into).

---

<div class="post-metadata">

**Author:** ![jim761](https://avatars.discourse-cdn.com/v4/letter/j/f14d63/32.png) [@jim761](https://discourse.jupyter.org/u/jim761)\
**Post date:** [October 3, 2021, 12:38am UTC](https://discourse.jupyter.org/t/change-default-working-directory-in-jupyterlab-on-linux/11066/3 "2021-10-03T00:38:32Z")

</div>

Thank you for answering here. I appreciated your SO answer. However, the part missing from your SO answer (unless I overlooked it) is:

```
jupyter server --generate-config

```

That might be obvious to some people, but all I knew was that the command you list there:

```
jupyter notebook --generate-config

```

was not what I needed since I’m running JupyterLab. Without your answer here, I was not able to put together the solution.

---

<div class="post-metadata">

**Author:** ![dalanicolai](https://yyz1.discourse-cdn.com/flex031/user_avatar/discourse.jupyter.org/dalanicolai/32/12745_2.png) [@dalanicolai](https://discourse.jupyter.org/u/dalanicolai)\
**Post date:** [March 15, 2024, 12:24pm UTC](https://discourse.jupyter.org/t/change-default-working-directory-in-jupyterlab-on-linux/11066/4 "2024-03-15T12:24:29Z")

</div>

The answer by @krassowski does not work for me on Fedora. It has an effect when starting ‘jupyter notebook’ but not when starting ‘jlab’. Also, first navigating to the ‘desired default directory’ and start ‘jlab’ from there doesn’t work.  
This looks to me like a bug.

Anyway, just before sending that I am unable to find a solution, I found the `--working-dir` flag/option. And fortunately, that solution works 🙂

---

<div class="post-metadata">

**Author:** ![krassowski](https://yyz1.discourse-cdn.com/flex031/user_avatar/discourse.jupyter.org/krassowski/32/1685_2.png) [@krassowski](https://discourse.jupyter.org/u/krassowski)\
**Post date:** [March 15, 2024, 12:45pm UTC](https://discourse.jupyter.org/t/change-default-working-directory-in-jupyterlab-on-linux/11066/5 "2024-03-15T12:45:28Z")

</div>

> Also, first navigating to the ‘desired default directory’ and start ‘jlab’ from there doesn’t work.

Use `jlab .` - the dot is important it means “current directory”.

But yes, `jlab` has a different CLI now which includes `--working-dir`. In general one can use `jlab --help`.
