# shortcuts

**Commands:**

| Usage                                 | Description                          |
| ------------------------------------- | ------------------------------------ |
| [*apolo attach*](#attach)             | Attach terminal to a job             |
| [*apolo cp*](#cp)                     | Copy files and directories           |
| [*apolo exec*](#exec)                 | Execute command in a running job     |
| [*apolo images*](#images)             | List images                          |
| [*apolo kill*](#kill)                 | Kill job(s)                          |
| [*apolo login*](#login)               | Log into Apolo Platform              |
| [*apolo logout*](#logout)             | Log out                              |
| [*apolo logs*](#logs)                 | Print the logs for a job             |
| [*apolo ls*](#ls)                     | List directory contents              |
| [*apolo mkdir*](#mkdir)               | Make directories                     |
| [*apolo mv*](#mv)                     | Move or rename files and directories |
| [*apolo port-forward*](#port-forward) | Forward port(s) of a job             |
| [*apolo ps*](#ps)                     | List all jobs                        |
| [*apolo pull*](#pull)                 | Pull an image from platform registry |
| [*apolo push*](#push)                 | Push an image to platform registry   |
| [*apolo rm*](#rm)                     | Remove files or directories          |
| [*apolo run*](#run)                   | Run a job                            |
| [*apolo save*](#save)                 | Save job's state to an image         |
| [*apolo share*](#share)               | Shares resource with another user    |
| [*apolo status*](#status)             | Display status of a job              |
| [*apolo top*](#top)                   | Display GPU/CPU/Memory usage         |

### attach

Attach terminal to a job

#### Usage

```bash
apolo attach [OPTIONS] JOB
```

Attach terminal to a job

Attach local standard input, output, and error streams to a running job.

#### Options

| Name                                      | Description                                                                                         |
| ----------------------------------------- | --------------------------------------------------------------------------------------------------- |
| *--help*                                  | Show this message and exit.                                                                         |
| *--port-forward LOCAL\_PORT:REMOTE\_RORT* | Forward port(s) of a running job to local port(s) (use multiple times for forwarding several ports) |

### cp

Copy files and directories

#### Usage

```bash
apolo cp [OPTIONS] [SOURCES]... [DESTINATION]
```

Copy files and directories.

Either `SOURCES` or `DESTINATION` should have storage:// scheme. If scheme is omitted, file:// scheme is assumed.

Use /dev/stdin and /dev/stdout file names to copy a file from terminal and print the content of file on the storage to console.

Any number of --exclude and --include options can be passed. The filters that appear later in the command take precedence over filters that appear earlier in the command. If neither --exclude nor --include options are specified the default can be changed using the storage.cp-exclude configuration variable documented in "apolo help user- config".

#### Examples

```bash

# copy local files into remote storage root
$ apolo cp foo.txt bar/baz.dat storage:
$ apolo cp foo.txt bar/baz.dat -t storage:

# copy local directory `foo` into existing remote directory `bar`
$ apolo cp -r foo -t storage:bar

# copy the content of local directory `foo` into existing remote
# directory `bar`
$ apolo cp -r -T storage:foo storage:bar

# download remote file `foo.txt` into local file `/tmp/foo.txt` with
# explicit file:// scheme set
$ apolo cp storage:foo.txt file:///tmp/foo.txt
$ apolo cp -T storage:foo.txt file:///tmp/foo.txt
$ apolo cp storage:foo.txt file:///tmp
$ apolo cp storage:foo.txt -t file:///tmp

# download other project's remote file into the current directory
$ apolo cp storage:/{project}/foo.txt .

# download only files with extension `.out` into the current directory
$ apolo cp storage:results/*.out .
```

#### Options

| Name                                 | Description                                                                                                                                                                                                                               |
| ------------------------------------ | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| *--help*                             | Show this message and exit.                                                                                                                                                                                                               |
| *--continue*                         | Continue copying partially-copied files.                                                                                                                                                                                                  |
| *--exclude-from-files FILES*         | A list of file names that contain patterns for exclusion files and directories. Used only for uploading. The default can be changed using the storage.cp-exclude-from-files configuration variable documented in "apolo help user-config" |
| *--exclude TEXT*                     | Exclude files and directories that match the specified pattern.                                                                                                                                                                           |
| *--include TEXT*                     | Don't exclude files and directories that match the specified pattern.                                                                                                                                                                     |
| *--glob / --no-glob*                 | Expand glob patterns in SOURCES with explicit scheme. *\[default: glob]*                                                                                                                                                                  |
| *-T, --no-target-directory*          | Treat DESTINATION as a normal file.                                                                                                                                                                                                       |
| *-p, --progress / -P, --no-progress* | Show progress, on by default in TTY mode, off otherwise.                                                                                                                                                                                  |
| *-r, --recursive*                    | Recursive copy, off by default                                                                                                                                                                                                            |
| *-t, --target-directory DIRECTORY*   | Copy all SOURCES into DIRECTORY.                                                                                                                                                                                                          |
| *-u, --update*                       | Copy only when the SOURCE file is newer than the destination file or when the destination file is missing.                                                                                                                                |

### exec

Execute command in a running job

#### Usage

```bash
apolo exec [OPTIONS] JOB -- CMD...
```

Execute command in a running job.

#### Examples

```bash

# Provides a shell to the container:
$ apolo exec my-job -- /bin/bash

# Executes a single command in the container and returns the control:
$ apolo exec --no-tty my-job -- ls -l
```

#### Options

| Name                       | Description                                                                                                                                                      |
| -------------------------- | ---------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| *--help*                   | Show this message and exit.                                                                                                                                      |
| *-t, --tty / -T, --no-tty* | Allocate a TTY, can be useful for interactive jobs. By default is on if the command is executed from a terminal, non-tty mode is used if executed from a script. |

### images

List images

#### Usage

```bash
apolo images [OPTIONS]
```

List images.

#### Options

| Name                 | Description                                                                     |
| -------------------- | ------------------------------------------------------------------------------- |
| *--help*             | Show this message and exit.                                                     |
| *--all-orgs*         | Show images in all orgs.                                                        |
| *--all-projects*     | Show images in all projects.                                                    |
| *--cluster CLUSTER*  | Show images on a specified cluster (the current cluster by default).            |
| *-l*                 | List in long format.                                                            |
| *--full-uri*         | Output full image URI.                                                          |
| *-n, --name PATTERN* | Filter out images by name regex.                                                |
| *--org ORG*          | Filter out images by org (multiple option, the current org by default).         |
| *--project PROJECT*  | Filter out images by project (multiple option, the current project by default). |

### kill

Kill job(s)

#### Usage

```bash
apolo kill [OPTIONS] JOBS...
```

Kill job(s).

#### Options

| Name     | Description                 |
| -------- | --------------------------- |
| *--help* | Show this message and exit. |

### login

Log into Apolo Platform

#### Usage

```bash
apolo login [OPTIONS] [URL]
```

Log into Apolo Platform.

`URL` is a platform entrypoint `URL`.

#### Options

| Name     | Description                 |
| -------- | --------------------------- |
| *--help* | Show this message and exit. |

### logout

Log out

#### Usage

```bash
apolo logout [OPTIONS]
```

Log out.

#### Options

| Name     | Description                 |
| -------- | --------------------------- |
| *--help* | Show this message and exit. |

### logs

Print the logs for a job

#### Usage

```bash
apolo logs [OPTIONS] JOB
```

Print the logs for a job.

#### Options

| Name                          | Description                                                                                                                              |
| ----------------------------- | ---------------------------------------------------------------------------------------------------------------------------------------- |
| *--help*                      | Show this message and exit.                                                                                                              |
| *--since DATE\_OR\_TIMEDELTA* | Only return logs after a specific date (including). Use value of format '1d2h3m4s' to specify moment in past relatively to current time. |
| *--timestamps*                | Include timestamps on each line in the log output.                                                                                       |

### ls

List directory contents

#### Usage

```bash
apolo ls [OPTIONS] [PATHS]...
```

List directory contents.

By default `PATH` is equal project's dir (storage:)

#### Options

| Name                             | Description                                          |
| -------------------------------- | ---------------------------------------------------- |
| *--help*                         | Show this message and exit.                          |
| *-d, --directory*                | list directories themselves, not their contents.     |
| *-l*                             | use a long listing format.                           |
| *-h, --human-readable*           | with -l print human readable sizes (e.g., 2K, 540M). |
| *-a, --all*                      | do not ignore entries starting with .                |
| *--sort \[name \| size \| time]* | sort by given field, default is name.                |

### mkdir

Make directories

#### Usage

```bash
apolo mkdir [OPTIONS] PATHS...
```

Make directories.

#### Options

| Name            | Description                                             |
| --------------- | ------------------------------------------------------- |
| *--help*        | Show this message and exit.                             |
| *-p, --parents* | No error if existing, make parent directories as needed |

### mv

Move or rename files and directories

#### Usage

```bash
apolo mv [OPTIONS] [SOURCES]... [DESTINATION]
```

Move or rename files and directories.

`SOURCE` must contain path to the file or directory existing on the storage, and `DESTINATION` must contain the full path to the target file or directory.

#### Examples

```bash

# move and rename remote file
$ apolo mv storage:foo.txt storage:bar/baz.dat
$ apolo mv -T storage:foo.txt storage:bar/baz.dat

# move remote files into existing remote directory
$ apolo mv storage:foo.txt storage:bar/baz.dat storage:dst
$ apolo mv storage:foo.txt storage:bar/baz.dat -t storage:dst

# move the content of remote directory into other existing
# remote directory
$ apolo mv -T storage:foo storage:bar

# move remote file into other project's directory
$ apolo mv storage:foo.txt storage:/{project}/bar.dat

# move remote file from other project's directory
$ apolo mv storage:/{project}/foo.txt storage:bar.dat
```

#### Options

| Name                               | Description                                        |
| ---------------------------------- | -------------------------------------------------- |
| *--help*                           | Show this message and exit.                        |
| *--glob / --no-glob*               | Expand glob patterns in SOURCES *\[default: glob]* |
| *-T, --no-target-directory*        | Treat DESTINATION as a normal file                 |
| *-t, --target-directory DIRECTORY* | Copy all SOURCES into DIRECTORY                    |

### port-forward

Forward port(s) of a job

#### Usage

```bash
apolo port-forward [OPTIONS] JOB LOCAL_PORT:REMOTE_RORT...
```

Forward port(s) of a job.

Forwards port(s) of a running job to local port(s).

#### Examples

```bash

# Forward local port 2080 to port 80 of job's container.
# You can use http://localhost:2080 in browser to access job's served http
$ apolo job port-forward my-fastai-job 2080:80

# Forward local port 2222 to job's port 22
# Then copy all data from container's folder '/data' to current folder
# (please run second command in other terminal)
$ apolo job port-forward my-job-with-ssh-server 2222:22
$ rsync -avxzhe ssh -p 2222 root@localhost:/data .

# Forward few ports at once
$ apolo job port-forward my-job 2080:80 2222:22 2000:100
```

#### Options

| Name     | Description                 |
| -------- | --------------------------- |
| *--help* | Show this message and exit. |

### ps

List all jobs

#### Usage

```bash
apolo ps [OPTIONS]
```

List all jobs.

#### Examples

```bash

$ apolo ps -a
$ apolo ps -a --owner=user-1 --owner=user-2
$ apolo ps --name my-experiments-v1 -s failed -s succeeded
$ apolo ps --description=my favourite job
$ apolo ps -s failed -s succeeded -q
$ apolo ps -t tag1 -t tag2
```

#### Options

| Name                                                                                  | Description                                                                                                                                                                                                    |
| ------------------------------------------------------------------------------------- | -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| *--help*                                                                              | Show this message and exit.                                                                                                                                                                                    |
| *-a, --all*                                                                           | Show all jobs regardless the status.                                                                                                                                                                           |
| *--all-orgs*                                                                          | Show jobs in all orgs.                                                                                                                                                                                         |
| *--all-projects*                                                                      | Show jobs in all projects.                                                                                                                                                                                     |
| *--cluster CLUSTER*                                                                   | Show jobs on a specified cluster (the current cluster by default).                                                                                                                                             |
| *-d, --description DESCRIPTION*                                                       | Filter out jobs by description (exact match).                                                                                                                                                                  |
| *--distinct*                                                                          | Show only first job if names are same.                                                                                                                                                                         |
| *--format COLUMNS*                                                                    | Output table format, see "apolo help ps-format" for more info about the format specification. The default can be changed using the job.ps-format configuration variable documented in "apolo help user-config" |
| *--full-uri*                                                                          | Output full image URI.                                                                                                                                                                                         |
| *-n, --name NAME*                                                                     | Filter out jobs by name.                                                                                                                                                                                       |
| *--org ORG*                                                                           | Filter out jobs by org name (multiple option, the current org by default).                                                                                                                                     |
| *-o, --owner TEXT*                                                                    | Filter out jobs by owner (multiple option). Supports `ME` option to filter by the current user.                                                                                                                |
| *-p, --project PROJECT*                                                               | Filter out jobs by project name (multiple option, the current project by default).                                                                                                                             |
| *--recent-first / --recent-last*                                                      | Show newer jobs first or last                                                                                                                                                                                  |
| *--since DATE\_OR\_TIMEDELTA*                                                         | Show jobs created after a specific date (including). Use value of format '1d2h3m4s' to specify moment in past relatively to current time.                                                                      |
| *-s, --status \[pending \| suspended \| running \| succeeded \| failed \| cancelled]* | Filter out jobs by status (multiple option).                                                                                                                                                                   |
| *-t, --tag TAG*                                                                       | Filter out jobs by tag (multiple option)                                                                                                                                                                       |
| *--until DATE\_OR\_TIMEDELTA*                                                         | Show jobs created before a specific date (including). Use value of format '1d2h3m4s' to specify moment in past relatively to current time.                                                                     |
| *-w, --wide*                                                                          | Do not cut long lines for terminal width.                                                                                                                                                                      |

### pull

Pull an image from platform registry

#### Usage

```bash
apolo pull [OPTIONS] REMOTE_IMAGE [LOCAL_IMAGE]
```

Pull an image from platform registry.

Remote image name must be `URL` with image:// scheme. Image names can contain tag.

#### Examples

```bash

$ apolo pull image:myimage
$ apolo pull image:/other-project/alpine:shared
$ apolo pull image:/project/my-alpine:production alpine:from-registry
```

#### Options

| Name     | Description                 |
| -------- | --------------------------- |
| *--help* | Show this message and exit. |

### push

Push an image to platform registry

#### Usage

```bash
apolo push [OPTIONS] LOCAL_IMAGE [REMOTE_IMAGE]
```

Push an image to platform registry.

Remote image must be `URL` with image:// scheme. Image names can contain tag. If tags not specified 'latest' will be used as value.

#### Examples

```bash

$ apolo push myimage
$ apolo push alpine:latest image:my-alpine:production
$ apolo push alpine image:/other-project/alpine:shared
```

#### Options

| Name     | Description                 |
| -------- | --------------------------- |
| *--help* | Show this message and exit. |

### rm

Remove files or directories

#### Usage

```bash
apolo rm [OPTIONS] PATHS...
```

Remove files or directories.

#### Examples

```bash

$ apolo rm storage:foo/bar
$ apolo rm storage:/{project}/foo/bar
$ apolo rm storage://{cluster}/{project}/foo/bar
$ apolo rm --recursive storage:/{project}/foo/
$ apolo rm storage:foo/**/*.tmp
```

#### Options

| Name                                 | Description                                              |
| ------------------------------------ | -------------------------------------------------------- |
| *--help*                             | Show this message and exit.                              |
| *--glob / --no-glob*                 | Expand glob patterns in PATHS *\[default: glob]*         |
| *-p, --progress / -P, --no-progress* | Show progress, on by default in TTY mode, off otherwise. |
| *-r, --recursive*                    | remove directories and their contents recursively        |

### run

Run a job

#### Usage

```bash
apolo run [OPTIONS] IMAGE [-- CMD...]
```

Run a job

`IMAGE` docker image name to run in a job.

`CMD` list will be passed as arguments to the executed job's image.

#### Examples

```bash

# Starts a container pytorch/pytorch:latest on a machine with smaller GPU resources
# (see exact values in `apolo config show`) and with two volumes mounted:
#   storage:/<home-directory>   --> /var/storage/home (in read-write mode),
#   storage:/neuromation/public --> /var/storage/neuromation (in read-only mode).
$ apolo run --preset=gpu-small --volume=storage::/var/storage/home:rw \
$ --volume=storage:/neuromation/public:/var/storage/home:ro pytorch/pytorch:latest

# Starts a container using the custom image my-ubuntu:latest stored in apolo
# registry, run /script.sh and pass arg1 and arg2 as its arguments:
$ apolo run -s cpu-small --entrypoint=/script.sh image:my-ubuntu:latest -- arg1 arg2
```

#### Options

| Name                                         | Description                                                                                                                                                                            |
| -------------------------------------------- | -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| *--help*                                     | Show this message and exit.                                                                                                                                                            |
| *--browse*                                   | Open a job's URL in a web browser                                                                                                                                                      |
| *--cluster CLUSTER*                          | Run job in a specified cluster                                                                                                                                                         |
| *-d, --description DESC*                     | Optional job description in free format                                                                                                                                                |
| *--detach*                                   | Don't attach to job logs and don't wait for exit code                                                                                                                                  |
| *--energy-schedule NAME*                     | Run job only within a selected energy schedule. Selected preset should have scheduler enabled.                                                                                         |
| *--entrypoint TEXT*                          | Executable entrypoint in the container (note that it overwrites `ENTRYPOINT` and `CMD` instructions of the docker image)                                                               |
| *-e, --env VAR=VAL*                          | Set environment variable in container. Use multiple options to define more than one variable. See `apolo help secrets` for information about passing secrets as environment variables. |
| *--env-file PATH*                            | File with environment variables to pass                                                                                                                                                |
| *-x, --extshm / -X, --no-extshm*             | Request extended '/dev/shm' space *\[default: x]*                                                                                                                                      |
| *--http-auth / --no-http-auth*               | Enable HTTP authentication for forwarded HTTP port *\[default: True]*                                                                                                                  |
| *--http-port PORT*                           | Enable HTTP port forwarding to container *\[default: 80]*                                                                                                                              |
| *--life-span TIMEDELTA*                      | Optional job run-time limit in the format '1d2h3m4s' (some parts may be missing). Set '0' to disable. Default value '1d' can be changed in the user config.                            |
| *-n, --name NAME*                            | Optional job name                                                                                                                                                                      |
| *--org ORG*                                  | Run job in a specified org                                                                                                                                                             |
| *--pass-config / --no-pass-config*           | Upload apolo config to the job *\[default: no-pass-config]*                                                                                                                            |
| *--port-forward LOCAL\_PORT:REMOTE\_RORT*    | Forward port(s) of a running job to local port(s) (use multiple times for forwarding several ports)                                                                                    |
| *-s, --preset PRESET*                        | Predefined resource configuration (to see available values, run `apolo config show`)                                                                                                   |
| *--priority \[low \| normal \| high]*        | Priority used to specify job's start order. Jobs with higher priority will start before ones with lower priority. Priority should be supported by cluster.                             |
| *--privileged*                               | Run job in privileged mode, if it is supported by cluster.                                                                                                                             |
| *-p, --project PROJECT*                      | Run job in a specified project.                                                                                                                                                        |
| *--restart \[never \| on-failure \| always]* | Restart policy to apply when a job exits *\[default: never]*                                                                                                                           |
| *--schedule-timeout TIMEDELTA*               | Optional job schedule timeout in the format '3m4s' (some parts may be missing).                                                                                                        |
| *--share USER*                               | Share job write permissions to user or role.                                                                                                                                           |
| *--tag TAG*                                  | Optional job tag, multiple values allowed                                                                                                                                              |
| *-t, --tty / -T, --no-tty*                   | Allocate a TTY, can be useful for interactive jobs. By default is on if the command is executed from a terminal, non-tty mode is used if executed from a script.                       |
| *-v, --volume MOUNT*                         | Mounts directory from vault into container. Use multiple options to mount more than one volume. See `apolo help secrets` for information about passing secrets as mounted files.       |
| *--wait-for-seat / --no-wait-for-seat*       | Wait for total running jobs quota *\[default: no-wait-for-seat]*                                                                                                                       |
| *--wait-start / --no-wait-start*             | Wait for a job start or failure *\[default: wait-start]*                                                                                                                               |
| *-w, --workdir TEXT*                         | Working directory inside the container                                                                                                                                                 |

### save

Save job's state to an image

#### Usage

```bash
apolo save [OPTIONS] JOB IMAGE
```

Save job's state to an image.

#### Examples

```bash
$ apolo job save job-id image:ubuntu-patched
$ apolo job save my-favourite-job image:ubuntu-patched:v1
$ apolo job save my-favourite-job image://bob/ubuntu-patched
```

#### Options

| Name     | Description                 |
| -------- | --------------------------- |
| *--help* | Show this message and exit. |

### share

Shares resource with another user

#### Usage

```bash
apolo share [OPTIONS] URI USER {read|write|manage}
```

Shares resource with another user.

`URI` shared resource.

`USER` username to share resource with.

`PERMISSION` sharing access right: read, write, or manage.

#### Examples

```bash
$ apolo acl grant storage:///sample_data/ alice manage
$ apolo acl grant image:resnet50 bob read
$ apolo acl grant job:///my_job_id alice write
```

#### Options

| Name     | Description                 |
| -------- | --------------------------- |
| *--help* | Show this message and exit. |

### status

Display status of a job

#### Usage

```bash
apolo status [OPTIONS] JOB
```

Display status of a job.

#### Options

| Name         | Description                 |
| ------------ | --------------------------- |
| *--help*     | Show this message and exit. |
| *--full-uri* | Output full URI.            |

### top

Display GPU/CPU/Memory usage

#### Usage

```bash
apolo top [OPTIONS] [JOBS]...
```

Display `GPU`/`CPU`/Memory usage.

#### Examples

```bash

$ apolo top
$ apolo top job-1 job-2
$ apolo top --owner=user-1 --owner=user-2
$ apolo top --name my-experiments-v1
$ apolo top -t tag1 -t tag2
```

#### Options

| Name                            | Description                                                                                                                                                                                                      |
| ------------------------------- | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| *--help*                        | Show this message and exit.                                                                                                                                                                                      |
| *--cluster CLUSTER*             | Show jobs on a specified cluster (the current cluster by default).                                                                                                                                               |
| *-d, --description DESCRIPTION* | Filter out jobs by description (exact match).                                                                                                                                                                    |
| *--format COLUMNS*              | Output table format, see "apolo help top-format" for more info about the format specification. The default can be changed using the job.top-format configuration variable documented in "apolo help user-config" |
| *--full-uri*                    | Output full image URI.                                                                                                                                                                                           |
| *-n, --name NAME*               | Filter out jobs by name.                                                                                                                                                                                         |
| *-o, --owner TEXT*              | Filter out jobs by owner (multiple option). Supports `ME` option to filter by the current user. Specify `ALL` to show jobs of all users.                                                                         |
| *-p, --project PROJECT*         | Filter out jobs by project name (multiple option).                                                                                                                                                               |
| *--since DATE\_OR\_TIMEDELTA*   | Show jobs created after a specific date (including). Use value of format '1d2h3m4s' to specify moment in past relatively to current time.                                                                        |
| *--sort COLUMNS*                | Sort rows by specified column. Add "-" prefix to revert the sorting order. Multiple columns can be specified (comma separated). *\[default: cpu]*                                                                |
| *-t, --tag TAG*                 | Filter out jobs by tag (multiple option)                                                                                                                                                                         |
| *--timeout FLOAT*               | Maximum allowed time for executing the command, 0 for no timeout *\[default: 0]*                                                                                                                                 |
| *--until DATE\_OR\_TIMEDELTA*   | Show jobs created before a specific date (including). Use value of format '1d2h3m4s' to specify moment in past relatively to current time.                                                                       |


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://docs.apolo.us/index/apolo-cli/commands/shortcuts.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
