I love the terminal feature and works very well for our use case where I would like students to do some work directly from a terminal so they experience that environment. The shell that launches automatically is sh and does not pick up all of my bash defaults. I can type "bash" and everything works perfectly. How can I make "bash" the default?
-
I guess it should pick up your default shell. What shell do you get if you open a normal terminal? – cel Nov 01 '15 at 21:22
-
With ssh, I am getting bash. I should track it down. – Steven Lowenthal Nov 02 '15 at 15:30
-
Did you ever fix this? If so how? – OneTwo Feb 04 '20 at 16:22
5 Answers
Jupyter uses the environment variable $SHELL to decide which shell to launch. If you are running jupyter using init then this will be set to dash on Ubuntu systems. My solution is to export SHELL=/bin/bash in the script that launches jupyter.
- 710
- 5
- 10
-
1I have set this in /etc/profile and /etc/environment and yet I still have the same problem, any ideas why? – OneTwo Feb 04 '20 at 16:21
-
One can also launch jupyter with `SHELL=/bin/bash jupyter-lab ...` – Vladimir Vargas Jul 24 '23 at 16:03
You can add this to your jupyter_notebook_config.py
c.NotebookApp.terminado_settings = {'shell_command': ['/bin/bash']}
- 176
- 1
- 5
-
1
-
You may need to use `c.ServerApp.terminado_settings` instead of `NotebookApp` in newer versions. – krassowski Aug 18 '22 at 18:29
-
With either `c.NotebookApp.terminado_settings` or `c.ServerApp.terminado_settings`, I'm getting the following error with Posit Workbench: `rstudio-server.service: Failed with result 'exit-code'` – sharchaea Jan 03 '23 at 17:55
I have tried the ultimate way of switching system-wide SHELL environment variable by adding the following line to the file /etc/environment:
SHELL=/bin/bash
This works on Ubuntu environment. Every now and then, the SHELL variable always points to /bin/bash instead of /bin/sh in Terminal after a reboot.
Also, setting up CRON job to launch jupyter notebook at system startup triggered the same issue on jupyter notebook's Terminal.
It turns out that I need to include variable setting and sourcing statements for Bash init file like ~/.bashrc in CRON job statement as follows via the command $ crontab -e :
@reboot source /home/USERNAME/.bashrc && \
export SHELL=/bin/bash && \
/SOMEWHERE/jupyter notebook --port=8888
In this way, I can log in the Ubuntu server via a remote web browser (http://server-ip-address:8888/) with opening jupyter notebook's Terminal default to Bash as same as local environment.
- 534
- 6
- 9
Since Jupyter server 2.0.0, --ServerApp.terminado_settings="shell_command=['/bin/bash']" should work.
For jupyterlab==3.6, I can confirm myself it works:
jupyter lab --ServerApp.terminado_settings="shell_command=['/bin/bash']"
See also Juptyer Server PR #949.
- 6,289
- 4
- 26
- 33
With Jupyter running on Ubuntu 15.10, the Jupyter shell will default into /bin/sh which is a symlink to /bin/dash.
rm /bin/sh
ln -s /bin/bash /bin/sh
That fix got Jupyter terminal booting into bash for me.
- 1
- 1