# Setting up Conda and JupyterLab on a Debian or Ubuntu

## Step 1: Update the System
```bash
sudo apt update && sudo apt upgrade
```

## Step 2: Install Dependencies
```bash
sudo apt install wget gpg python3 python3-pip
```

## Step 3: Download and Verify Miniconda
```bash
cd ~/Downloads
```
```bash
wget https://repo.anaconda.com/miniconda/Miniconda3-latest-Linux-x86_64.sh
```
```bash
sha256sum -c Miniconda3-latest-Linux-x86_64.sh.sha256
```

## Step 4: Install Miniconda
```bash
bash Miniconda3-latest-Linux-x86_64.sh
```
During the installation, answer the prompts as follows:
- Review the license agreement and enter "yes" to accept.
- Press Enter to confirm the installation location or specify a custom location.
- Enter "no" when asked to initialize Conda.

## Step 5: Initialize Conda
```bash
eval "$(/home/medusa/miniconda3/bin/conda shell.bash hook)"
conda init
source ~/.bashrc
conda config --set auto_activate_base false
```

## Step 6: Create and Activate a Conda Environment
```bash
conda create --name myenv python=3.12
conda activate myenv
```

## Step 7: Install JupyterLab and Packages
```bash
python3 -m pip install --upgrade pip
python3 -m pip install jupyterlab numpy pandas matplotlib
```

## Step 8: Configure JupyterLab for Remote Access
```bash
jupyter lab --generate-config
vim ~/.jupyter/jupyter_lab_config.py
```
Uncomment and modify the following lines:
```python
c.ServerApp.ip = '0.0.0.0'  # Set to your server's IP or '0.0.0.0' for all interfaces
c.ServerApp.port = 8888  # Set to your desired port
c.ServerApp.open_browser = False
```

## Step 9: Set a Password for JupyterLab
```bash
jupyter lab password
```

## Step 10: Save and Use the Environment Configuration

### A. Export the Environment Configuration
```bash
conda env export > environment.yml
```

### B. Create a New Environment Using the Configuration File
```bash
conda env create -f environment.yml
```

### C. Update an Existing Environment Using the Configuration File
```bash
conda env update --file environment.yml --prune
```

### D. Share and Version Control the Configuration File
- Store the `environment.yml` file in a GitHub repository along with your project files.
- To recreate the environment on another machine, navigate to the directory containing the `environment.yml` file and run:
  ```bash
  conda env create -f environment.yml
  ```

### E. Deactivate and Remove an Environment
- To deactivate the current environment:
  ```bash
  conda deactivate
  ```
- To remove an environment:
  ```bash
  conda env remove --name myenv
  ```

## Step 11: Start JupyterLab
```bash
jupyter lab
```

## Step 12: Access JupyterLab
Open a web browser on your local machine and navigate to `http://your_server_ip:8888`.

## Step 13: Deactivate the Environment
```bash
conda deactivate
```

## Additional Notes
- Replace `medusa` with your actual username and `myenv` with your desired environment name.
- Consider using SSH tunneling, a reverse proxy with SSL, or firewall rules for enhanced security.
- If you need to make the `conda` command available in your shell after the Miniconda installation, run:
  ```bash
  eval "$(/home/medusa/miniconda3/bin/conda shell.bash hook)"
  ```

This guide includes all the essential steps and additional details such as saving and using the environment configuration file, sharing and version controlling the configuration file, deactivating and removing environments, and making the `conda` command available in the shell after installation.