> ## Documentation Index
> Fetch the complete documentation index at: https://support.labex.io/llms.txt
> Use this file to discover all available pages before exploring further.

# Virtual machine and terminal in the LabEx app

> Start and stop the lab VM, use terminals and forwarded ports on iPhone and Mac, and know when pricing or limits apply.

Many labs need a **Linux environment**. The app attaches a **virtual machine (VM)** to the current lab so you can run commands in a real terminal.

The VM is a **side tool**: reading steps and chatting with Labby stays in the main learning layout. The terminal is there when the lab expects hands-on work.

For background on LabEx VMs in the browser, see [Virtual Machine](/en/using-labex/virtual-machine). This page stays focused on **app controls**.

The **iPhone** sections below use iPhone screenshots. The **Mac** section includes a **macOS** screenshot of the learning workspace with the embedded terminal and assistant.

## When the VM starts

* Use the **VM** entry from the learning UI when you need the terminal.
* On the **first step**, the **primary Continue button** may also start the VM **if** the lab still needs an environment and you do not already have a usable session for this lab.

If the lab **does not allow** starting a VM on your current plan, the app opens **pricing** instead of starting hardware.

## iPhone: VM sheet

On **iPhone**, the VM opens as a **sheet** you drag between medium and large heights.

* **Idle**\
  You see a short explanation and **Start VM**.

<img src="https://mintcdn.com/huhuhang/25nKqG9Xc_zEKLCv/images/labex-app-ios-vm-start-sheet.png?fit=max&auto=format&n=25nKqG9Xc_zEKLCv&q=85&s=7ccfca5fd22944bdca2cab72134ecc90" alt="LabEx on iPhone: VM sheet before start, with the desktop preview" width="460" height="1000" data-path="images/labex-app-ios-vm-start-sheet.png" />

* **Running**\
  You get quick actions (for example **paste** and **clear terminal**) and a settings area for **interfaces**, **stop**, **back to terminal**, and **exposed ports**.

While the environment is preparing, the sheet shows **setup progress** and remaining session time.

<img src="https://mintcdn.com/huhuhang/25nKqG9Xc_zEKLCv/images/labex-app-ios-vm-setup-progress.png?fit=max&auto=format&n=25nKqG9Xc_zEKLCv&q=85&s=49162b6806c0029403822972e02b5c16" alt="LabEx on iPhone: VM sheet showing setup progress" width="460" height="1000" data-path="images/labex-app-ios-vm-setup-progress.png" />

The **more** menu reaches **Interfaces** (switch tty sessions) and **Stop VM** while the machine is running.

<img src="https://mintcdn.com/huhuhang/25nKqG9Xc_zEKLCv/images/labex-app-ios-vm-settings-menu.png?fit=max&auto=format&n=25nKqG9Xc_zEKLCv&q=85&s=03c15f143771ac0612ffeeda13dcdf0b" alt="LabEx on iPhone: VM sheet menu with Interfaces and Stop VM" width="460" height="1000" data-path="images/labex-app-ios-vm-settings-menu.png" />

**Clear terminal** runs the `clear` command in the session; it does not erase your device clipboard.

## Mac: workspace and sidebar

On **Mac**, the terminal lives in the **learning workspace**, not as the only full-screen sheet.

When the VM is running, **Learning** in the sidebar lists **terminals** and **exposed ports** in one flat list. Use the **+** menu next to **Learning** to **add a terminal** or **add an exposed port** (you type the port number in a small form).

Select a row to switch what the embedded browser shows. **Return to terminal** jumps back to your tty session.

<img src="https://mintcdn.com/huhuhang/PMseQv1n5XTf81ND/images/labex-app-macos-vm-workspace.png?fit=max&auto=format&n=PMseQv1n5XTf81ND&q=85&s=3498071f6e4de05045d7eefbb4aefe3f" alt="LabEx on macOS: embedded terminal in the workspace with assistant and verification panel" width="1200" height="847" data-path="images/labex-app-macos-vm-workspace.png" />

## Multiple terminals and ports

Labs can use more than one terminal. The app assigns **reserved high ports** for web terminals and can **forward extra ports** you choose.

* You can **add** another terminal until you reach the limit.
* You can **close** a terminal you no longer need, except the **last** one, which must stay open.

Only **one terminal web view** is shown at a time; switching rows swaps the active URL.

## Session time and extend (Pro)

VMs expire after a scheduled time. The app shows **remaining time** and may prompt you when time is low.

* **LabEx Pro** users may see an option to **extend** the session when the app enters a short final window before expiry.
* **Free** users see guidance that points to **pricing** instead.

After you extend or the session ends, trust the **on-screen timer** and any alerts the app shows.

## Stop and conflicts

**Stop VM** ends the remote session and clears local terminal state.

If a VM is already running for **another lab**, starting a new one can **conflict**. The app explains the situation and lets you **keep the old lab** or **replace** it with the new one. If you replace, the old VM is removed first.

If you hit a **temporary VM quota** limit, the app opens **pricing** so you can review Pro options.

## Paste and shortcuts

Toolbar actions can **paste** into the terminal and send common keys. Some paste helpers treat **paths** differently (for example, they may send Enter so a command runs). Plain paste from the toolbar does **not** auto-send Enter.

## If something looks wrong

* **Switching labs** clears old terminal URLs so you never stay attached to the wrong lab by mistake.
* **Stopping**, **errors**, or **expiry** reset the VM UI to an idle state until you start again.
