<\/span><\/h2>\n\n\n\nFirst, log in to your Ubuntu 20.04 server via SSH as the root user:<\/p>\n\n\n\n
ssh root@IP_Address -p Port_number<\/pre>\n\n\n\nOnce logged in, update your system packages with the following command:<\/p>\n\n\n\n
apt-get update -y<\/pre>\n\n\n\n <\/figure>\n\n\n\n<\/span>Install Required Dependencies<\/span><\/h2>\n\n\n\nJupyter Notebook is based on Python. So you will need to install Python and other libraries to your system. You can install all of them with the following command:<\/p>\n\n\n\n
apt-get install python3 python3-pip python3-dev -y<\/pre>\n\n\n\nNext, verify the installed version of Python with the following command:<\/p>\n\n\n\n
python3 --version<\/pre>\n\n\n\nOutput:<\/p>\n\n\n\n
Python 3.8.5\n<\/pre>\n\n\n\nNext, upgrade the PIP to the latest version using the following command:<\/p>\n\n\n\n
pip3 install --upgrade pip<\/pre>\n\n\n\nNext, verify the PIP version with the following command:<\/p>\n\n\n\n
pip3 --version<\/pre>\n\n\n\nOutput:<\/p>\n\n\n\n
pip 20.0.2 from \/usr\/lib\/python3\/dist-packages\/pip (python 3.8)<\/pre>\n\n\n\nNext, install the Virtual Environment package with the following command:<\/p>\n\n\n\n
pip3 install virtualenv<\/pre>\n\n\n\n<\/span>Install Jupyter Notebook<\/span><\/h2>\n\n\n\nFirst, create a separate user for Jupyter Notebook. You can create it with the following command:<\/p>\n\n\n\n
adduser jupyter<\/pre>\n\n\n\nNext, log in with Jupyter user with the following command:<\/p>\n\n\n\n
su - jupyter<\/pre>\n\n\n\nNext, create a Jupyter directory and create a virtual environment for Jupyter notebook.<\/p>\n\n\n\n
mkdir ~\/Jupyter\ncd ~\/Jupyter\nvirtualenv notebook<\/pre>\n\n\n\nNext, activate the virtual environment with the following command:<\/p>\n\n\n\n
source notebook\/bin\/activate<\/pre>\n\n\n\nNext, install the Jupyter with the following command:<\/p>\n\n\n\n
(notebook) jupyter@jupyter:~\/Jupyter$ pip install jupyter<\/pre>\n\n\n\nOnce installed, run the Jupyter notebook with the following command:<\/p>\n\n\n\n
(notebook) jupyter@jupyter:~\/Jupyter$ jupyter notebook<\/pre>\n\n\n\nYou should get the following output:<\/p>\n\n\n\n
[I 06:12:57.527 NotebookApp] Writing notebook server cookie secret to \/home\/jupyter\/.local\/share\/jupyter\/runtime\/notebook_cookie_secret\n[I 06:12:57.786 NotebookApp] Serving notebooks from local directory: \/home\/jupyter\/Jupyter\n[I 06:12:57.786 NotebookApp] Jupyter Notebook 6.3.0 is running at:\n[I 06:12:57.787 NotebookApp] http:\/\/localhost:8888\/?token=9a7e565bbe40a36e7afbcd9cda890823288c61312e9f1eed\n[I 06:12:57.787 NotebookApp] or http:\/\/127.0.0.1:8888\/?token=9a7e565bbe40a36e7afbcd9cda890823288c61312e9f1eed\n[I 06:12:57.787 NotebookApp] Use Control-C to stop this server and shut down all kernels (twice to skip confirmation).\n[W 06:12:57.791 NotebookApp] No web browser found: could not locate runnable browser.\n[C 06:12:57.791 NotebookApp] \n\n To access the notebook, open this file in a browser:\n file:\/\/\/home\/jupyter\/.local\/share\/jupyter\/runtime\/nbserver-11919-open.html\n Or copy and paste one of these URLs:\n http:\/\/localhost:8888\/?token=9a7e565bbe40a36e7afbcd9cda890823288c61312e9f1eed\n or http:\/\/127.0.0.1:8888\/?token=9a7e565bbe40a36e7afbcd9cda890823288c61312e9f1eed\n<\/pre>\n\n\n\nPress CTRL+C to stop the Jupyter Notebook.<\/p>\n\n\n\n
Next, you will need to generate a configuration file for Jupyter Notebook. You can generate it with the following command:<\/p>\n\n\n\n
(notebook) jupyter@jupyter:~\/Jupyter$ jupyter notebook --generate-config<\/pre>\n\n\n\nYou should get the following output:<\/p>\n\n\n\n
Writing default config to: \/home\/jupyter\/.jupyter\/jupyter_notebook_config.py<\/pre>\n\n\n\nNext, set the password for Jupyter with the following command:<\/p>\n\n\n\n
(notebook) jupyter@jupyter:~\/Jupyter$ jupyter notebook password<\/pre>\n\n\n\nYou should see the following output:<\/p>\n\n\n\n
Enter password: \nVerify password: \n[NotebookPasswordApp] Wrote hashed password to \/home\/jupyter\/.jupyter\/jupyter_notebook_config.json\n<\/pre>\n\n\n\nNext, deactivate from the Python virtual environment with the following command:<\/p>\n\n\n\n
(notebook) jupyter@jupyter:~\/Jupyter$ deactivate<\/pre>\n\n\n\nNext, logout from the Jupyter user with the following command:<\/p>\n\n\n\n
exit<\/pre>\n\n\n\n<\/span>Create a Systemd Service File for Jupyter<\/span><\/h2>\n\n\n\nNext, you will need to create a systemd service file to manage the Jupyter Notebook. You can create it with the following command:<\/p>\n\n\n\n
nano \/etc\/systemd\/system\/jupyter.service<\/pre>\n\n\n\nAdd the following lines:<\/p>\n\n\n\n
[Unit]\nDescription=Jupyter Notebook\n\n[Service]\nType=simple\nPIDFile=\/run\/jupyter.pid\nExecStart=\/home\/jupyter\/Jupyter\/notebook\/bin\/jupyter-notebook --config=\/home\/jupyter\/.jupyter\/jupyter_notebook_config.py\nUser=jupyter\nGroup=jupyter\nWorkingDirectory=\/home\/jupyter\/Jupyter\/notebook\nRestart=always\nRestartSec=10\n\n[Install]\nWantedBy=multi-user.target\n<\/pre>\n\n\n\nSave and close the file then reload the systemd daemon with the following command:<\/p>\n\n\n\n
systemctl daemon-reload<\/pre>\n\n\n\nNext, start the Jupyter service and enable it to start at system reboot with the following command:<\/p>\n\n\n\n
systemctl start jupyter\nsystemctl enable jupyter<\/pre>\n\n\n\nYou can also verify the status of the Jupyter with the following command:<\/p>\n\n\n\n
systemctl status jupyter<\/pre>\n\n\n\nOutput:<\/p>\n\n\n\n
\u25cf jupyter.service - Jupyter Notebook\n Loaded: loaded (\/etc\/systemd\/system\/jupyter.service; disabled; vendor preset: enabled)\n Active: active (running) since Tue 2021-04-06 06:32:47 UTC; 2min 33s ago\n Main PID: 14630 (jupyter-noteboo)\n Tasks: 1 (limit: 2353)\n Memory: 40.6M\n CGroup: \/system.slice\/jupyter.service\n \u2514\u250014630 \/home\/jupyter\/Jupyter\/notebook\/bin\/python \/home\/jupyter\/Jupyter\/notebook\/bin\/jupyter-notebook --config=\/home\/jupyter\/.jup>\n\nApr 06 06:32:47 jupyter systemd[1]: Started Jupyter Notebook.\nApr 06 06:32:48 jupyter jupyter-notebook[14630]: [I 06:32:48.023 NotebookApp] Serving notebooks from local directory: \/home\/jupyter\/Jupyter\/no>\nApr 06 06:32:48 jupyter jupyter-notebook[14630]: [I 06:32:48.024 NotebookApp] Jupyter Notebook 6.3.0 is running at:\nApr 06 06:32:48 jupyter jupyter-notebook[14630]: [I 06:32:48.024 NotebookApp] http:\/\/localhost:8888\/\nApr 06 06:32:48 jupyter jupyter-notebook[14630]: [I 06:32:48.024 NotebookApp] Use Control-C to stop this server and shut down all kernels (twi>\nApr 06 06:32:48 jupyter jupyter-notebook[14630]: [W 06:32:48.030 NotebookApp] No web browser found: could not locate runnable browser.\n<\/pre>\n\n\n\n