How to install JupyterHub bash kernel to run bash code on Jupyter notebook

H
Programming language support comes in the form of a kernel on JupyterHub. The Python kernel is installed by default on JupyterHub which enables the Python programming language on Jupyter Notebooks. You can also use other programming languages ​​on your Jupyter Notebook. All you need to do is install the appropriate kernel for JupyterHub on your computer.

In this article, we will show you how to install the JupyterHub bash kernel on your JupyterHub server so that JupyterHub users can run bash code on their Jupyter notebooks.

Comment: If JupyterHub is not installed on your computer, you can read one of the following articles depending on the Linux distribution you are using:

1. How to Install the Latest Version of JupyterHub on Ubuntu 22.04 LTS/Debian 12/Linux Mint 21

2. How to Install Latest Version of JupyterHub on Fedora 38+/RHEL 9/Rocky Linux 9

Contents:

  1. Installing JupyterHub Bash Kernel for Single User
  2. Installing JupyterHub Bash Kernel for All Users
  3. conclusion
  4. Reference

Installing JupyterHub Bash Kernel for Single User

If you are a JupyterHub user and do not have super-user (root) privileges, you can install the Bash kernel on Jupyter Hub only for your JupyterHub account.

First, log in to your JupyterHub account and click on “Terminal” from the “Launcher” tab.

You should be able to access Python PIP on the terminal.

To install the JupyterHub bash kernel Python module, run the following commands:

, pip3 to install bash_kernel

Installing the JupyterHub Bash Kernel Python module. It takes some time to complete.

At this point, the JupyterHub Bash Kernel Python module should be installed.

To install the JupyterHub bash kernel to your JupyterHub account, run the following command:

, Python3 -M bash_kernel.install

To see the changes, refresh the JupyterHub homepage and you should see “Bash” in the “Notebook” section of JupyterHub. Click on it to create a Bash Jupyter notebook.

A new Jupyter notebook should be created and a Bash kernel selected for the notebook.

You can run and document Bash code in this notebook just like you would Python code.

Installing JupyterHub Bash Kernel for All Users

If you have administrative privileges on the JupyterHub server, you can install the JupyterHub bash kernel for all JupyterHub users. This saves a lot of hassle for JupyterHub users as well as saves a lot of disk space and reduces data redundancy on the JupyterHub server.

To install the JupyterHub bash kernel Python module on the JupyterHub virtual environment, run the following command:

, sudo ,choose,jupyterhub,bin,Python3 -M pip to install bash_kernel

The JupyterHub Bash Kernel Python module must be installed on the JupyterHub virtual environment.

To install the JupyterHub bash kernel (on the JupyterHub virtual environment) for all JupyterHub users, run the following command:

, sudo ,choose,jupyterhub,bin,Python3 -M bash_kernel.install

As you can see, JupyterHub bash kernel is installed.

, sudo ,choose,jupyterhub,bin,jupyter-kernelspec list

Now, any JupyterHub user can find the option to create a Bash notebook on the JupyterHub “Launcher” tab.

To create a Bash Jupyter notebook, click “Bash” from the “Notebook” section of the JupyterHub “Launcher” tab.

A Bash Jupyter Notebook must be created.

You can run and document Bash code in this notebook just like you would Python code.

conclusion

In this article, we showed you how to install the JupyterHub Bash kernel on your JupyterHub server so that JupyterHub users can run and document Bash code on their Jupyter notebook, just like they do Python code.

Reference:

Add comment

By Ranjan