---
title: CLI
description: >-
  Create and manage Studios (ie: "VMs") via the CLI. To use the Lightning CLI,
  first install the Lightning SDK: pip install lightning-sdk -U CLI commands...
canonical: 'https://lightning.ai/docs/platform/build/ai-studio/cli'
---
# CLI {#cli}

Create and manage Studios (ie: "VMs") via the CLI.

## Installation {#installation}

To use the Lightning CLI, first install the Lightning SDK:

```bash
pip install lightning-sdk -U
```

## Basic Usage {#basic-usage}

CLI commands follow the syntax

```bash
lightning [command]
```

Get help on possible commands by running

```bash
lightning COMMAND --help
```

## Authentication {#authentication}

Authentication persists across sessions. Log in to use the CLI commands by running `lightning login` and entering your credentials in the browser tab that opens.

## Create Studio {#create-studio}

Create new Studios from the terminal by running

```bash
lightning studio create --teamspace <OWNER/TEAMSPACE_NAME> --name <STUDIO_NAME>


```

Both `--name` and `--teamspace` are optional. In case --name is not specified, the Studio will be named randomly and in case --teamspace is not specified, it will ask interactively which teamspace to use (or take it from the config if specified).

## Start Studio {#start-studio}

Start an already existing Studio with

```bash
lightning studio start --name <STUDIO_NAME> --teamspace <OWNER_NAME>/<TEAMSPACE_NAME> --machine T4
```

Similar to Studio creation `--name` and `--teamspace` are optional, where it will ask for both of them if not specified as arguments or in the config file.

## Stop Studio {#stop-studio}

Stop a running Studio with:

```bash
lightning studio stop --name <STUDIO_NAME> --teamspace <OWNER_NAME>/<TEAMSPACE_NAME>
```

When omitting `--name` and/or `--teamspace`, the CLI will prompt for them if it cannot resolve them from the environment.

## Switch Studio Machine {#switch-studio-machine}

Switching already running Studios to a different machine, can be achieved with:

```bash
lightning studio switch --name <STUDIO_NAME> --teamspace <OWNER_NAME>/<TEAMSPACE_NAME> --machine H100
```

## Upload local files to Studio {#upload-local-files-to-studio}

Upload files or folders from your local workspace to a selected Studio. Studios do not need to be running to use this operation. Note that folders need the recursive flag (i.e. `lightning cp -r`)

```bash
lightning cp [LOCAL_PATH] [STUDIO_PATH]

lightning cp -r [LOCAL_PATH] [STUDIO_PATH]
```

**Arguments and Flags**

- `LOCAL_PATH` (Required/str): The path to the local file or folder to upload
- `STUDIO_PATH` (Required/str): The path to the file or folder within the Studio. Format: `lit://{org}/{teamspace_name}/studios/{studio_name}/{studio_path}`, or `lit:///studios/{studio_name}/{studio_path}` for a Studio in the current teamspace
- `-r` or `--recursive` (Required for folders): Must be specified when uploading folders

**Examples**

Upload a file to a specific studio:

To upload `main.py` to your Studio named `my-studio` in the `my-teamspace` teamspace of the `my-org` organization, use the following command:

```bash
lightning cp ./main.py lit://my-org/my-teamspace/studios/my-studio/local_main.py
```

Upload a directory to a specific location in a studio:

To upload a folder `./tests/` to the same Studio, use the following command:

```bash
lightning cp -r ./tests/ lit://my-org/my-teamspace/studios/my-studio/local_tests/
```

Drop the org and teamspace to address a Studio in the teamspace you are already working in:

```bash
lightning cp ./main.py lit:///studios/my-studio/local_main.py
```

## Download studio files {#download-studio-files}

Download files and folders to your local workspace from studios. Studios do not need to be running to use this operation. Note that folders need the recursive flag (i.e. `lightning cp -r`)

```bash
lightning cp [STUDIO_PATH] [LOCAL_PATH]

lightning cp -r [STUDIO_PATH] [LOCAL_PATH]
```

**Arguments and flags**

- `STUDIO_PATH` (Required/str): The path to the file within the Studio. Format: `lit://{org}/{teamspace_name}/studios/{studio_name}/{studio_path}`, or `lit:///studios/{studio_name}/{studio_path}` for a Studio in the current teamspace
- `LOCAL_PATH` (Required/str): The path locally where files will be downloaded to
- `-r` or `--recursive` (Required for folders): Must be specified when downloading folders

**Examples**

Download a file from a specific studio:

To download `main.py` from your Studio named `my-studio` in the `my-teamspace` teamspace of the `my-org` organization, use the following command:

```bash
lightning cp lit://my-org/my-teamspace/studios/my-studio/main.py ./studio_main.py
```

Download a directory to a specific local location:

To download the folder `~/tests/` from the same Studio, use the following command:

```bash
lightning cp -r lit://my-org/my-teamspace/studios/my-studio/tests/ ./
```

*Note: you can not download files from an s3 connection*

Download the entire studio:

```bash
lightning cp -r lit://my-org/my-teamspace/studios/my-studio/ ./
```

## List, remove, and edit studio files {#list-remove-and-edit-studio-files}

`lightning ls` lists a Studio's files without downloading them, `lightning rm` deletes them, and `lightning edit` opens one in your local editor and saves it back. All three take the same URLs as `lightning cp`:

```bash
lightning ls -r lit://my-org/my-teamspace/studios/my-studio/tests/
lightning rm lit:///studios/my-studio/main.py
lightning edit lit:///studios/my-studio/main.py
```

See the [Teamspace Drive CLI reference](/docs/platform/developers/cli/drive.md) for the full flags and URL syntax.

## List Studios {#list-studios}

Listing existing studios can be done with

```bash
lightning studio list
```

## Accessing Studio via SSH {#accessing-studio-via-ssh}

To access Studios via SSH run:

```bash
lightning studio ssh --teamspace <OWNER/TEAMSPACE_NAME> --name <STUDIO_NAME>
```

This will directly open a shell in the specified Studio. As with all other commands, the `--name` and `--teamspace` flags are optional and will be prompted for if not specified but required for Studio resolution.

---

**Navigation**

- Parent: [AI Studio (workspace)](/docs/platform/build/ai-studio.md)
